in reply to Recalling the URL of initiating page
I've been using $ENV{REQUEST_URI} under apache for a long time and it seems to work good.
You could consider checking the configuration of your webserver or the correct set of your environment variables. :P