Copy and paste this into an error404.php file hosted on your PHP-enabled web server:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>404 Error: Document Not Found!</title></head><body><?php mail("your@email.com","404 report: ".getenv("REQUEST_URI"),getenv("SERVER_NAME").getenv("REQUEST_URI")."nFrom: ".getenv("HTTP_REFERER")."n".getenv("REMOTE_ADDR")." • ".getenv("HTTP_USER_AGENT")."n".date("D M j Y g:i:s a T"),"From: error404-3ice.hu@example.comrn"); ?></p>
<h1>Error 404: Document Not Found!</h1>
<p>The <code><?php echo getenv("SERVER_NAME").getenv("REQUEST_URI") ?></code> page was not found on this server.</p>
<hr />
<p style="text-align:right">Date: <?php echo date("D M j Y g:i:s a T") ?></p>
<p></body></html>
Insert this line into the end of your .htaccess file in the root directory of your public html folder:
ErrorDocument 404 /error404.php
(Valid XHTML!) And don't forget to change "your@email.com" to your real email address. You will get a new email every time someone tries to access a broken URL on your site. The sender is "error404-3ice.hu@example.com" by default, but you can change that easily in the PHP script.
The report includes: Broken URL, URL where the visitor came from, IP address of the visitor, UserAgent of the visitor, and Time of the visit.
May 20th, 2010 at 12:54 am
lol!
Strange thing to post :D
But does work!
August 21st, 2014 at 10:28 pm
I better change the example email address to end in example.com, since I've been getting some spam on the previous address recently.
Edit: Done. But the damage has already been done, the spambots have my address now.