Create a phpinfo page (phpinfo.php):
<?
phpinfo();
?>
Look through the page and you will see many variables you can use through get_env(NAME)
This will allow you to grab things as mention like PHP_SELF, SCRIPT_NAME and much more. There's probably something you're looking for there.
-Tim