How can I write htaccess to do the following:
redirect ALL dead links on www.mysite.com to www.mysite.com (homepage)
Obviously I only want the dead links redirected.
Thanks
Just redirect 404 (missing) files to a path you want
ErrorDocument 404 http://www.somesite.gov/
or just go home...
ErrorDocument 404 /
remember that ErrorDocument 404 http://www.somesite.gov/ will actually hand the search engines a 302 or temporary redirect and won't remove those pages from the search engines.
ErrorDocument 404 / is probably more correct as it will generate a 404, but will send the person to the homepage. Any graphics and links should have absolute relative paths or you should put a <base href="/"> to make sure everything displays properly.
This should also do it, and pass the failed page as an argument:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?badrequest=$1
I haven't tested it mind.