Redirecting 404 error with .htaccess via 301 for SEO etc

Chris picture Chris · Mar 2, 2010 · Viewed 117.3k times · Source

I couldn't find a straight answer to my question and need to know it from the real experts.

I had a website which urls were generated by Joomla. I believe that tons of urls are around in the search engines and I really don't know which of them all. A 302 redirect would be an option, but I can't say which urls need to be redirected.

The only thing I know that all the urls were generated by a sef404 script, it's a SEO script for Joomla.

My question, how can I make sure that all the orphan urls on google and other search engines are delivered correctly with a .htaccess file?

How do I 301 redirect all 404 pages to the homepage (root document)

At the moment I use a custom 404.html error file, but there are too many files and will give a rollercoaster of custom 404 error pages

Answer

andrew picture andrew · Jan 1, 2013

I came up with the solution and posted it on my blog

http://web.archive.org/web/20130310123646/http://onlinemarketingexperts.com.au/2013/01/how-to-permanently-redirect-301-all-404-missing-pages-in-htaccess/

here is the htaccess code also

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]

but I posted other solutions on my blog too, it depends what you need really