Question

In my .htacess rule i have rule like

ErrorDocument 404 randomsite.com/404page.php

In my 404page.php, i m not able track the page from which i got 404 page.

Example:

If i click link "randomsite.com/notexists" its redirecting to my 404page.php but when i print_r($_SERVER) on 404page.php there is no mention of notexist url.

So how can i track my 404 pages.

Was it helpful?

Solution

First you should use ErrorDocument with full path not relative:

ErrorDocument 404 /randomsite.com/404page.php

Then to get the actual URI for which you got 404 page you should use:

$_SERVER["REQUEST_URI"]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top