Get php script path in CGI, and SAPI?
Posted: Sun Jun 24, 2007 3:07 pm
The post only refers to PHP >= 5.1...
Say I have a PHP script at:
http://localhost/~username/script.php
I can get the "/~username/script.php" part by looking in $_SERVER["SCRIPT_NAME"] when using CGI and when using the apache module.
Now if I go to this URL:
http://localhost/~username/script.php/foo/bar
It's still loading script.php as it should be, but now under SAPI, SCRIPT_NAME is just like it was before, whereas in CGI SCRIPT_NAME has been screwed up (I can't even make sense of why it does this):
URL:
http://php5host/~d11wtq/Router/demo.php/foo/bar
SCRIPT_NAME as seen in SAPI:

I knew there were discrepencies with CGI and SAPI in terms of what $_SERVER contains, but does anyone know how I can get the "~d11wtq/Router/demo.php" part in both CGI and SAPI with a pretty high chance of success? It doesn't have to be 100% perfect since it's settable anyway.
Say I have a PHP script at:
http://localhost/~username/script.php
I can get the "/~username/script.php" part by looking in $_SERVER["SCRIPT_NAME"] when using CGI and when using the apache module.
Now if I go to this URL:
http://localhost/~username/script.php/foo/bar
It's still loading script.php as it should be, but now under SAPI, SCRIPT_NAME is just like it was before, whereas in CGI SCRIPT_NAME has been screwed up (I can't even make sense of why it does this):
URL:
http://php5host/~d11wtq/Router/demo.php/foo/bar
SCRIPT_NAME as seen in SAPI:
SCRIPT_NAME as seen in CGI:[SCRIPT_NAME] => /~d11wtq/Router/demo.php
It's truncated[SCRIPT_NAME] => tq/Sites/Router/demo.php
I knew there were discrepencies with CGI and SAPI in terms of what $_SERVER contains, but does anyone know how I can get the "~d11wtq/Router/demo.php" part in both CGI and SAPI with a pretty high chance of success? It doesn't have to be 100% perfect since it's settable anyway.