Posted at Jan 29, 2009 12:17:36 PM by Taylor De Luca | Share
So you've got lots of traffic and your blog/site is becoming more and more popular. If you've done any kind of update, rearrangement of the site you may have loose ends that just lead nowhere resulting in those pesky 404 pages. It's often difficult to track these down unless you dive into your traffic reporting Cpanel software but that's sometimes a daunting task and often yields mixed results.
One solution would be to simply make a more intelligent 404 page and adjust and fix the site accordingly as you collect the necessary information. This nifty little PHP script both notifies the user at to what may have gone wrong, as well as send out a detailed report to you with the users IP address, what they were looking for and when they were looking for it. It'll even tell you what platform/browser they were using at the time.
Another benefit of using a script like this is that you can track when someone is trying to hack through your directories looking for something they shouldn't be. From there you can just block their IP and be on your way.
The great thing about this is all you have to do is drop this in your 404 page, adjust the email addresses at the bottom to match your own and you're almost done. Once you've got the script in your 404 page you'll need to make sure all errors redirect to this page. Add this to your .htaccess file
ErrorDocument 404 /404.html
ErrorDocument 404 /404.php
depending on what your 404 page is and give it a try.