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.

Comments

nicholasthompson’s picture

Assigned: Unassigned » nicholasthompson
Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Ah crap - good point!

I'll commit this asap!

foutrelis’s picture

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. :)

sethcohn’s picture

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.

sethcohn’s picture

Status: Reviewed & tested by the community » Needs work

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.

sethcohn’s picture

Better issue for more documentation on why you can't use base_path()

#219916: Call to undefined function base_path()

foutrelis’s picture

Status: Needs work » Needs review
StatusFileSize
new705 bytes

Great catch sethcohn! I updated the patch to use $GLOBALS['base_path'].

nicholasthompson’s picture

Version: 5.x-1.3 » 5.x-1.x-dev
Status: Needs review » Fixed

Committed to latest DEV release - will appear in next official release...
http://drupal.org/cvs?commit=130598

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

David Lesieur’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Active

In my setup, Drupal runs in a subdirectory, but requests are rewritten so the subdirectory does not appear in URLs. Therefore, the following condition in globalredirect_init() always apply, preventing Global Redirect from working normally:

if ($_SERVER['SCRIPT_NAME'] != $GLOBALS['base_path'] .'index.php') return FALSE;

As I understand it, this condition aims at telling whether the current script is really Drupal's, but I'm not sure how to define this condition in my context...

nicholasthompson’s picture

Status: Active » Fixed

Fixed in 6.x-1.x-dev and in 5.x-dev which are about to get branched into releases very soon.

nicholasthompson’s picture

Status: Fixed » Closed (duplicate)

Ok I've just noticed that use of $GLOBALS['base_path'] - although syntactically correct - doesn't solve the problem as the base path is relative to the file doing the bootstrap.

This simple fixes the problem if the issue is a module having a bootstrapping file which isn't called "index.php".

Marking as duplicate of #304025: not working when drupal is installed in a subdirectory

bartoll’s picture

sub+