PDA

View Full Version : Do you ever review your 404 errors?



KLB
08-03-2006, 01:41 PM
So does anyone else review their 404 errors?

I have my 404 error page set to log errors to a separate text file from my main server log so that I don't have to crunch my logs to find the errors. Anyways what if find really humorous are the bad back links people create to my site and I don't mean from junk spammer sites either. Here are some examples:

Wrong: /yogi/Biohazard/placards/class1.html
Right: /yogi/hazmat/placards/class1.html

Wrong: /yogi/U.html
Right: /yogi/periodic/U.html
(Someone linked to every one of my element pages forgetting to add "periodic/")

Wrong: /yogi/periodic/Mn.html.html
Right: /yogi/periodic/Mn.html
(I see all types of goofy stuff at the end of URLs)

I almost think that people do not test their links when they make a page. I even found links on various language Wikipedia.org sites to pages on my site that never existed (it was for one of the unnamed elements).

The point of all of this is that by tracking 404 errors and redirecting those that you can to a real page you not only improve the user experience (they get to what they were looking for) but also make it easier for search engines to index your site and maybe recover some credit for what would otherwise be a lost back link.

Here are some .htaccess instructions I use to reroute the most common linking errors (note that all webpages on my site end in ".html"):

RewriteRule ^([a-z|A-Z|0-9].*)\.php /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.html>(.*) /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.html-(.*) /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.html(.)Enviro(.*) /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.html(.)E /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)/(.)target= /$1/ [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.html(.)target= /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)/default\.htm$ /$1/ [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.htm$ /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.ht$ /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.h$ /$1.html [R=301,L]
RewriteRule ^([a-z|A-Z|0-9].*)\.$ /$1 [R=301,L]

KelliShaver
08-03-2006, 03:51 PM
Tracking 404's and rewriting them to the right place is a good idea if you can find out where they should really be going and the page is actually on the site.

Wouldn't it be better for the SE's to issue a 301 redirect to the proper page, though? (I honestly have no idea)

KLB
08-03-2006, 04:07 PM
The redirects I use like the ones above do issue 301 redirects to the proper page. And yes it is always a good idea to use 301 redirects when redirecting a page.

Every now and then I can't figure out where the request was really trying to go to, but most of the time it is very apparent even on a site as large as mine. If you also record the referrer information for the bad request you can sometimes find the page that has the bad link and at least figure out what they had intended.

KLB
08-03-2006, 05:59 PM
Okay I've been adding more goofy misspellings of my URLs and it seems my top level folder "/yogi/" is really tough to spell. I thought I'd share another batch of rewrites I have had to add in my .htaccess file:

RewriteRule ^vogi/(.*) /yogi/$1 [R=301,L]
RewriteRule ^yoga/(.*) /yogi/$1 [R=301,L]
RewriteRule ^yoxi/(.*) /yogi/$1 [R=301,L]
RewriteRule ^togi/(.*) /yogi/$1 [R=301,L]
RewriteRule ^yoig/(.*) /yogi/$1 [R=301,L]
RewriteRule ^yohi/(.*) /yogi/$1 [R=301,L]
RewriteRule ^yog/(.*) /yogi/$1 [R=301,L]

Now if I could go back to 1995, one of the things that I would have done differently is I wouldn't have put that stupid folder in as the primary folder for all of my webpages, but at the time it seemed logical. Even six or seven years ago there were so many links to my site with that stupid folder name that I really couldn't remove it and I'll forever have a nonsensical directory name in my URLs. The reason I put that folder in back in 1995 was I called my site "YOGI'S Behemoth" (Yogi was my nickname) and it seemed like a good idea at the time. What I have learned about the word 'yogi' is that our Japanese and Chinese friends seem to have a devil of a time spelling it.

KelliShaver
08-03-2006, 10:48 PM
Oh, I see the 301 in there now. I just totally overlooked it last time. :/