HTAccess Please Help!

4 replies
Hello Guys,

I know that we should have a custom 404 page before anyone points this out but this is not possible right now for various reasons.

What I want to do is 301 all 404 pages to the homepage. I tried doing this in htaccess:

ErrorDocument 404 /

But it only creates a 302 redirect, we need a 301 for SEO reasons!

Please can someone advise me what to put into my htaccess file?

Thanks very much!

RuFFCuT

Thanks very much!

RuFFCuT
#htaccess
  • Profile picture of the author Ricky Dawn
    I cannot find out how to redirect them all with 301's.

    your idea worked but only redirected it as a 302.

    Thanks

    Ricky
    {{ DiscussionBoard.errors[5937286].message }}
  • Profile picture of the author CyberAlien
    You could adding this to your htaccess:

    ErrorDocument 404 /permanent.php
    redirect 301 /permanent.php http://yourwebsite.com


    That will send all pages not found to permanent.php and then 301 redirect all hits to permanent.php to your homepage. I haven't tried that but it makes sense
    {{ DiscussionBoard.errors[5937344].message }}
  • Profile picture of the author Ricky Dawn
    Yeah I know what you mean, but the reason I want to do a 301 is so I can pass the most link juice for SEO.

    The way you have done it still requires it to go via a 302 at first

    Thanks for your input!

    Ricky
    {{ DiscussionBoard.errors[5938186].message }}
    • Profile picture of the author SilkySmooth
      Hi Ricky,

      If you have mod_rewrite enabled on your hosting you should be able to use the following:

      Code:
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule (.*) http://www.yourdomain.com/ [L,R=301]
      The rewritecond basically says if the file doesn't exist then apply the rule which will issue with a 301. Keep in mind that if you have other rules for rewriting then you need to make sure the above is placed after your other rewrites.
      {{ DiscussionBoard.errors[5938505].message }}

Trending Topics