I have made this with my pages that are database generated with $_GET, but im starting to notice 404s from pages that are not database generated.
for example maybe incorrect directory name:
site.com/mispelleddir/page-name
or somehow the dir got printed twice:
site.com/dir/dir/page-name
I want to know that URL that was tried. Is there a way i can fetch the requested URL that gave a 404 into a php variable or something so i can include that in my error report? and or the page that it was linked to. I know i can see that sort of thing on google webmaster tools, but it takes them 2 days before they can report it to me. And usually in that time i could have fixed the problem already.
right now i have an email sent to me reporting it from the 404 page:
function report404($body)
{
$to = "my email @gmail.com";
$subject = "website 404 error report";
if (!mail($to, $subject, $body))
echo("<p>Message delivery failed...</p>");
}
used like this on the 404 page:
if($_GET['page']) report404("The sentence [$page] was sent to eng.php or jap.php and could not generate a translation page.");
else report404("404 error occured but not from eng.php or jap.php");
when my database driven pages dont find the content in the db they redirect to 404 page setting the ?page="attempted page" but this wont work if the 404 error was trigger by those above examples.