Originally Posted by Rick
Well, the problem is that SCRIPT_FILENAME just contains the path to the script, it doesn't contain anything after it.

So, something like this:

https://www.ubbcentral.com/forums/ubbthreads.php/ubb/showflat/Number/216111

SCRIPT_FILENAME only contains:

https://www.ubbcentral.com/forums/ubbthreads.php/ubb/showflat

It chops off the actual data that we need to know what topic to show.

Did you check the apache settings? Looking at the PHP documentation:
http://www.php.net/manual/en/reserved.variables.server.php
'PATH_TRANSLATED'
Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.

Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it's set to the same value as the SCRIPT_FILENAME server variable when it's not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined.
Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO.

also this is found for php5:
http://www.php.net/manual/en/migration5.incompatible.php
PATH_TRANSLATED server variable is no longer set implicitly under Apache2 SAPI in contrast to the situation in PHP 4, where it is set to the same value as the SCRIPT_FILENAME server variable when it is not populated by Apache. This change was made to comply with the » CGI specification. Please refer to » bug #23610 for further information, and see also the $_SERVER['PATH_TRANSLATED'] description in the manual. This issue also affects PHP versions >= 4.3.2.

Also a non elegant workaround is:
if (!defined(’MAIN_EXEC_DIR’)) define(’MAIN_EXEC_DIR’, dirname(__FILE__));

Then MAIN_EXEC_DIR would always contain the information you are looking for. Certainly, it’s a pain to have to put this in every file, though.


I think the code that finds out the path should become a little smarter to use different ways to find out what the complete URL is.