superUntitled superUntitled - 1 month ago 13
PHP Question

PHP: using $SERVER[] to return the current directory, regardless of "nice urls"

I am trying to return the current directory of a file in php, regardless what it says in the browser bar. I have tried:


If the url is

the above code returns

even though var1/var2/var3 are
variables tamed by a htaccess RewriteRule. Is there a decent way to get the directory? in the case above I would like to return:



How about replace it with SCRIPT_FILENAME ?

str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname($_SERVER['SCRIPT_FILENAME']));