[wp-hackers] Re: [wp-svn] [2744] trunk/wp-settings.php: Fixes #1488

Nikolay Bachiyski nbachiyski at developer.bg
Wed Aug 3 11:25:09 GMT 2005

Robert Deaton wrote:
> Reading around, PHP_SELF is set on all platforms but does not contain
> the same information, specifically in regular cgi mode vs php-cgi
> mode. If anybody has time to test various server setups to confirm.

Hmm, Robert is right. For example under mod_php the request to
results in

My initial suggestions is to use SCRIPT_NAME if php is not run as cgi. 
If php is running as cgi we can quite safely (can we really?) disregard 
everything after the extension of the script name in PHP_SELF.

However, some further tests on different servers/sapi's will be really 
useful. If anybody is willing to test, we  shall need the following four 
	- request uri
	- output of php_sapi_name()
	- value of $_SERVER['SCRIPT_NAME']
	- value of $_SERVER['PHP_SELF']


> On 8/3/05, Nikolay Bachiyski <nbachiyski at developer.bg> wrote:
>>m at wordpress.org wrote:
>>> // Fix for IIS, which doesn't set REQUEST_URI
>>>-if (! isset($_SERVER['REQUEST_URI'])) {
>>>+if ( empty( $_SERVER['REQUEST_URI'] ) ) {
>>>+     $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
>>It does not (or at least - not always). When php scripts are run in cgi
>>environment (I have tested on Apache only) the SCRIPT_NAME variable is
>>set to "/cgi-bin/php4-wrapper" or something equally unusable for our
>>purposes. However the PHP_SELF variable always gives us the relative
>>path to the current script.
>>wp-hackers mailing list
>>wp-hackers at lists.automattic.com

More information about the wp-hackers mailing list