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]
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]