PDA

View Full Version : Help discovering 404 origin


network23
06-28-2005, 05:08 PM
This seemd to be the best topic...

Looking at my stats pages, I see that my site gets a lot of 404 hits. The problem comes from the fact that I have very little idea what pages the visitors were TRYING to reach when they got the 404 in the first place.

Is there any way to glean that info from the site logs, or is there some installable php or perl script that will help me find out what page(s) my visitors are trying to load when they get the 404?

Jason
06-28-2005, 06:02 PM
This free log analyzer should do it for you:

http://awstats.sourceforge.net/

nix
06-29-2005, 04:39 PM
This seemd to be the best topic...

Looking at my stats pages, I see that my site gets a lot of 404 hits. The problem comes from the fact that I have very little idea what pages the visitors were TRYING to reach when they got the 404 in the first place.

Is there any way to glean that info from the site logs, or is there some installable php or perl script that will help me find out what page(s) my visitors are trying to load when they get the 404?

If you have Cpanel, it has that info in it. If not, make your 404 an shtml file and insert this code in:

<!--#echo var="REQUEST_URI" -->

I haven't quite figured out the writing down of the URL requested but its a start. There is a PHP method too I'm sure, but you have to change your 404 page to a .php instead. Then copy the header that the person got a 404 with, and have the page email you with the info about the page being requested. I'll look it up on how to do that.

*edit:

$error = $_SERVER['REQUEST_URI'];
mail("youremailaddress@abc.com","404 Error at your site!", "This page encountered the 404 error: $error", "From: mysite.com");

I haven't tried it yet, but I trust the source. Give it a go, but remember to make sure it's in a .php document. and also make sure the .htaccess is pointing to a .php document too. ;)