Any chance of getting this ported to Drupal 6.x?


There certainly is a chance. All I need is a little time to try out Drupal 6.x... I was under the impression that some menu stuff chx did would have made Global Redirect obsolete. I shall investigate :-)

The links in the menu are changed to the proper 'nice' URL, but if you go to /node/ID it does not redirect...

EDIT: Any progress here?

Version:7.x-1.x-dev» 6.x-1.x-dev

I assume Process == progress? ;-)

I'm going to work on this today... :-)

Fine... :-) You might get no fun with hook_boot... (url() and path alias functions are not available at this bootstrap) and this could end up with using hook_init as today... :-(.

Status:Active» Fixed

Cool. Are you able to add a 6.x-1.x-dev build to the project page, please? :-)

I'd love to but I can quite see how ;-)

I've created the project node for it and 6.x-dev is appearing in the releases part of the project....

Status:Fixed» Needs work

1. Open
2. click "Add new release"
3. select the branch
4. click next... wait until 14:00 or 2:00 :-).

Aside the D6 version totally break my site... it redirect paths that shouldn't be redirected and therefor break everything.

I've added the release already -

Its odd how it broke your site - i tested it on a dev version of D6 (HEAD) which I checked out about 5 minutes before getting GR to work. I tested it on nodes with and without aliases. I also had it working with clean and unclean URL's (ie, unclean redirecting to clean).

I'll check my dev version again...

Every click i do ends up in a redirection failure. Admin section becomes inaccessible, batch api breaks on module activation and so on.

Are you using the latest HEAD of D6 or RC1?

I can confirm that GR is working on my HEAD version of D6. I just rechecked out Drupal HEAD and GR (DRUPAL-6--1) and admin is perfectly usable for me - and urls with aliases redirect correctly...

Is this the version you are using?

Priority:Normal» Critical

Sorry, it is broken. I used the DRUPAL-6--1 from CVS. If i activate the module i get an endless loop. Remember - we have had this in past, too.

GET /drupal6/admin/build/modules HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: Gecko/20071127 Firefox/
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: de,en;q=0.8,en-us;q=0.6,de-de;q=0.4,es;q=0.2
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost/drupal6/batch?op=start&id=5
Cookie: SESSa955ad6f1f4200d67d8e737cf8f39496=6uocfprbi4ok8q2rkpav8vr795; SESS3454e17132c3e54c94e5d4e0ee6996c4=ou2r6o4gc2hiug0afufe99ert4; SESS7f96114f5554854dcd79508f31e86ad5=vvbkkf8bcuqhi2c3c2qh8thpd2; has_js=1; SESS382051e6e1ed8806a7f7ff8f96fa26b4=g6f8b5n1k4mj544nr2t05nkon1
HTTP/1.x 301 Undescribed
Server: Microsoft-IIS/5.1
Date: Sun, 30 Dec 2007 12:14:24 GMT
Connection: close
X-Powered-By: PHP/5.2.4
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Sun, 30 Dec 2007 12:14:23 GMT
Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-Type: text/html; charset=utf-8
Location: http://localhost/drupal6/admin/build/modules


I do recall this in the past - but that was to do with GR ignoring the destination argument.

I notice you're using IIS - I use Apache (on RedHat)... I wonder if this has anything to do with it...

Are you using Clean URL's?

Yes, clean URLs are activated.

I gave clean url setting a try and if disabled it works.

Title:Drupal 6.xIIS with ISAPI_ Rewrite & clean_url ends with endless loop

Ok, the source if this bug is this line...

if ((bool)variable_get('clean_url', 0) && strpos(request_uri(), '?q=')) {

I remember IIS will every time show '?q=' to the PHP script with ISAPI Rewrite... cannot say for sure now, but i debugged this in past for something else and learned there is a difference between Apache and IIS with ISAPI Rewrite. See about the difference. Apache gives you the clean URL as variable and all other webservers not... therefor the request_uri() does not contain '?q=', but does on all other webservers.

Aside, this is why we use JS in D6 to detect clean URLs for all servers for sure... prior Drupal releases have made us to add an hardcoded line to settings.php telling Drupal to turn on clean_urls ($conf['clean_url'] = 1;).

Therefor the check in line 1681 continuously fails on non Apache servers.

Title:IIS with ISAPI_ Rewrite & clean_url ends with endless loopDrupal 6.x


Ok - so the question now is how to get IIS to test if the URI is clean or not clean if clean_url is enabled. IDEALLY it'd be nice to not have to use JS to do this...

Unfortunately, I do not have IIS installed. Does WinXP Pro come with IIS? I have a parallels install with WinXP Pro on it...

PS: Do you use Skype or anything?

Title:Drupal 6.xIIS with ISAPI_ Rewrite & clean_url ends with endless loop

Bloody Firefox didn't refresh the form!

Status:Needs work» Needs review
new1.78 KB

Patch attached that fixes this bug.

Category:task» bug

Yes, IIS comes with WinXP Pro.

Category:bug» task

Looks good - I'll give that a go (just about to go out)....

Just out of interest, is there any reason why you're using 'strstr' instead of 'strpos'?

There is also the 'issue' of what happens if you're using a server which isn't Apache or IIS (does LightHTTP claim to be an apache derivative?) - Is it safe to assume that any non-IIS server will react in the same way as IIS? If so - then we could switch that arround and check for IIS and just to a 'catch all' else as an alternative...

Thanks for the patch Hass!

Status:Needs review» Needs work

I figured out any problem with forms not saved... let's do some more testing... maybe limit this redirection to GET only.

Well we could limit this to IIS... but we have the risk to be broken on other servers, too. The way you get the variable is only provided by mod_rewrite. If other rewrite plugins works different it get's broken again.

May i ask you - if this POST data not saved problem is a general problem!?

Category:bug» task
new1.82 KB

1. Added method GET, but i'm not sure of this is save for GET forms... only tested with POST forms.
2. Changed strstr to strpos.

If you'd don't like to be save, this code may work as expected (untested).

// If no alias was returned, the final check is to direct non-clean to clean - if clean is enabled.
if ((bool)variable_get('clean_url', 0) && $_SERVER['REQUEST_METHOD'] == 'GET') {
// IIS do not have mod_rewrite and the url in REQUEST_URI produce an endless loop here.
if (strpos($_SERVER['SERVER_SOFTWARE'], 'IIS')) {
// ISAPI_Rewrite 2.x and 3.x Filter will provide the clean_url in the variable HTTP_X_REWRITE_URL on IIS.
if (isset($_SERVER['HTTP_X_REWRITE_URL']) && strpos($_SERVER['HTTP_X_REWRITE_URL'], '?q=')) {
drupal_goto($request, $query_string, NULL, 301);
// All other webservers that are 100% mod_rewrite compatible and provide a clean_url in REQUEST_URI.
elseif (strpos(request_uri(), '?q=')) {
drupal_goto($request, $query_string, NULL, 301);

Or we need to turn off the last redirect check on IIS at all.

//If no alias was returned, the final check is to direct non-clean to clean - if clean is enabled
if ((bool)variable_get('clean_url', 0) && strpos(request_uri(), '?q=') && !strpos($_SERVER['SERVER_SOFTWARE'], 'IIS')) {
drupal_goto($request, $query_string, NULL, 301);

Category:task» bug
Status:Needs work» Needs review

Could we maybe do a check at the beginning of hook_init to check if $_POST is empty? We obviously cant check if $_GET is empty because of '?q='... But if there is something in $_POST then we never want to interrupt it with a redirect.

I'm not 100% sure what the problem is here though... Would you mind explaining what exactly goes wrong?

Status:Needs review» Fixed

GR does an empty check on $_POST now. If there is ANYTHING in $_POST, then GR doesn't do any redirecting. Hopefully this will solve this issue...

Status:Fixed» Needs review

@nicholas: I don't think so... if you do a strpos(request_uri(), '?q=') on the URL you are running an endless loop... Not sure what ISAPI version I've used in past, but I'm sure this is also the case with the newest version. I will give it a try again and keep you posted. See #18.

How are things going to get this all fixed & integrated either into GR or back into Drupal. I can still not use GR on my D6 / IIS site.


I'm having this problem with Apache. :S

These are the headers as reported by Live HTTP Headers:

HTTP/1.x 302 Moved Temporarily
Date: Sat, 11 Jul 2009 00:07:03 GMT
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0, no-cache
Expires: Sun, 19 Nov 1978 05:00:00 GMT
X-Powered-By: PHP/5.2.6
Content-Type: text/html; charset=iso-8859-1
X-Cache: MISS from Accel0
X-Cache-Lookup: MISS from Accel0:8080
Connection: close

Note the reported Apache version and the 302 response code. I've confirmed that the request_uri() function returns the non-clean url, thus it enters and endless loop.

Has anyone tested this with IIS7 and the URL Rewrite module?

I have D6 and IIS7 on windows server and it's working fine

Title:IIS with ISAPI_ Rewrite & clean_url ends with endless loopIIS <=6 with ISAPI_ Rewrite & clean_url ends with endless loop

Version:6.x-1.x-dev» 6.x-1.2
Issue tags:+IIS6, +Global Redirect, +windows server, +iirf, +endless loop

Thank you post #27, I used your code and modified it to work with the most recent version of Global Redirect 6.x-1.2. We're on IIS6, Drupal 6. Thanks again!

Line 153 of /globalredirect/globalredirect.module

// If no alias was returned, the final check is to direct non-clean to clean - if clean is enabled
if ((variable_get('globalredirect_nonclean2clean', GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED) == GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED) && ((bool)variable_get('clean_url', 0)) && strpos(request_uri(), '?q=')) {
      if (
strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') && isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '?q=')) {
drupal_goto($request, $query_string, NULL, 301);
// ISAPI_Rewrite 3.x Filter will provide the clean_url in the variable HTTP_X_REWRITE_URL on IIS.
elseif (strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') && isset($_SERVER['HTTP_X_REWRITE_URL']) && strpos($_SERVER['HTTP_X_REWRITE_URL'], '?q=')) {
drupal_goto($request, $query_string, NULL, 301);