Quote:
|
Originally Posted by StephenR
I was just thinking....You may be aware that Google recently updated its Adsense TOS. You can now add Adsense to 404 pages!
|
I have some pretty comprehensive .htaccess instructions and PHP code that do 301 redirects to get almost all lost users to the right pages on my site. One of the best sets of .htaccess rules I have that would help any site reduce the most common "lazy" 404 errors are:
RewriteRule ^([a-z|0-9].*)\.html.+$ /$1.html? [NC,R=301,L]
RewriteRule ^([a-z|0-9].*)/(.)target= /$1/? [NC,R=301,L]
RewriteRule ^([a-z|0-9].*)/default\.htm$ /$1/? [NC,R=301,L]
RewriteRule ^([a-z|0-9].*)\.htm$ /$1.html? [NC,R=301,L]
RewriteRule ^([a-z|0-9].*)\.ht$ /$1.html? [NC,R=301,L]
RewriteRule ^([a-z|0-9].*)\.h$ /$1.html? [NC,R=301,L]
RewriteRule ^([a-z|0-9].*)\.$ /$1? [NC,R=301,L]
RewriteRule ^([a-z|0-9].*)>$ /$1? [NC,R=301,L]
Now obviously this assumes that the file extension used for pages is only .html. This also assumes that one uses index.html, not default.htm for directory index pages. Note, you might need to add your domain name to the target URL depending on your server configuration.
Oh the trailing question mark on the target URL is to strip off query strings.