volomike/Faster — Issue #15: Base URL Not Properly Discovered
Author: volomike
Created: 2011-10-30 04:09:40+00:00
State: open
Labels: Bug

I found one really strange web host where the base URL was not properly discovered. This was due to a wacky configuration where the $_SERVER['DOCUMENT_ROOT'] parameter was not returning the proper result.

This led me to discover a really bad couple of lines in index.php, which I should never have done. These are the only lines that deal with DOCUMENT_ROOT. The line looks like this:

```$sPath = str_replace('\\', '/', substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])));```

As you can see, that's kind of a blind line -- super risky!

The fix is to replace that line with this:

```$sPath = str_replace('index.php','',$_SERVER['SCRIPT_NAME']);```

It is in the baseurl() and the getPath() functions.