Global Redirect fails if Drupal is installed inside a subdirectory
foutrelis - July 4, 2008 - 16:59
| Project: | Global Redirect |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | nicholasThompson |
| Status: | closed |
Description
globalredirect.module: line 25: if ($_SERVER['SCRIPT_NAME'] != '/index.php') return false;
That line always returns false on my site and I think it's because my installation is inside a subdirectory, so $_SERVER['SCRIPT_NAME'] is actually "/myfolder/index.php".
It seems sensible to use base_dir().'index.php' instead. Attached for review is a patch that does that.
| Attachment | Size |
|---|---|
| globalredirect_base_dir.patch | 695 bytes |

#1
Ah crap - good point!
I'll commit this asap!
#2
It's been two weeks and as far as I know, this bug still exists in 5.x-1.3-1 which was released four days after your reply.
Please look into it when you have time. :)
#3
Bump. I got bit by this during an upgrade of the module into a development subdirectory install. Please commit this ASAP, as it completely stop redirection without it if your site is not at the webroot directory.
#4
OOPS! Important Correction:
You CANNOT use base_path(), because common.inc isn't called by hook_init.
Per http://drupal.org/node/174366#comment-709393
You can (and likely should) use:
$GLOBALS['base_path'] instead.
#5
Better issue for more documentation on why you can't use base_path()
#219916: Call to undefined function base_path()
#6
Great catch sethcohn! I updated the patch to use $GLOBALS['base_path'].
#7
Committed to latest DEV release - will appear in next official release...
http://drupal.org/cvs?commit=130598
#8
Automatically closed -- issue fixed for two weeks with no activity.