I want to fetch the actual URL of the request made by the client, how do I do that? I mean if someone requests a page that does not exists, like, http://localhost/invalid.php
, and I have set 404 custom error file to http://localhost/test.php
, then how do I get to know what was the actual URL requested by the user.
I have tried this in IIS7. I have set the Custom Error Page to /test.php, and whenever the user requests a URL which does not exist, I could still access that URL using $_SERVER['REQUEST_URI'] in /test.php and the URL in browsers still remains the same.
But I am having problem doing the same in Apache. I have set the Custom Error Page to /test.php but when user requests a page which doesn't exist, the user is redirected to a /test.php and I cant access the actual URL which the user requested. I've tried this print_r($_SERVER)
but did not find the actual request URL any where in the $_SERVER
array.