1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Some experience with .htaccess, 301's & resulting 404 errors

Discussion in 'Black Hat SEO' started by thedorf, Dec 2, 2013.

  1. thedorf

    thedorf Supreme Member

    Oct 1, 2008
    Likes Received:
    what? I gotta have a job?
    BHW - Where else?
    I use the .htaccess method for redirecting my websites. I *believe* it is the fast type redirect (faster than php, javascript, asp.net redirects).

    I was digging about my websites and redirects when I noticed some pages in Google, for the redirected site (recently dropped), producing 404 errors on my money site.

    Here is the deal. You can do multiple type redirects in the .htaccess file.

    One way is:

    RewriteEngine On
    RewriteBase /
    RewriteRule (.*) http://www.redirectedWebsite.com/$1 [R=301,L] 
    and another way is:

    RewriteEngine On
    RewriteBase /
    RewriteRule (.*) http://www.redirectedWebsite.com.net/ [R=301,L] 
    the difference being the $1 at the end of the first redirect. That $1 says to redirect all pages as they are called hence www.redirectedsite.com/goofypage.html will become www.yourMoneySite.com/goofypage.html
    and can produce a 404 error on your money site unless you have a page called goofypage.html on your website or -

    if you have a 404 page in your .htaccess as such:

    RewriteEngine On
    RewriteBase /
    ErrorDocument 404 /404.php
    which will forward all 404 errors to 404.php. A couple of notes here:

    1) do not use your homepage to refer your 404's to. Why? Because then you will have multiple copies of your homepage (duplicate content penalty) on your website. Leave that for another less important landing page.

    2) The RewriteEngine On RewriteBase / is only needed once within the .htaccess.

    3) Using the redirect without the $1 will result in all pages being forwarded (in the instance above) to your homepage, which is probably what you want, at least it is what I want, as my homepage is my best landing page.
    • Thanks Thanks x 1
    Last edited: Dec 2, 2013
  2. tahworld

    tahworld Regular Member

    Aug 16, 2013
    Likes Received:
    Don't forget:

    ErrorDocument 400
    ErrorDocument 401
    ErrorDocument 403
    ErrorDocument 404
    ErrorDocument 500