301 Redirects: Why and How

By DChapman · Feb 8, 2006 ·
  1. DChapman
    Open your browser of choice and type: [noparse]http://google.com[/noparse] into the address bar and hit enter. Watch closely, [noparse]http://google.com[/noparse] redirects to [noparse]http://www.google.com[/noparse]. This is because Google has a "301 redirect" setup. A 301 redirect is a permanent redirect of one webpage to another. There are many different ways to utilize a 301 redirect. For the purpose of this article, we will only discuss the redirect of [noparse]http://domain.com[/noparse] to [noparse]http://www.domain.com[/noparse] (or vice versa) via .htaccess. What is the point of this 301 redirect and how do you properly implement one?

    What is the point of 301 redirects?

    Believe it or not, in the eyes of search engines, [noparse]http://domain.com[/noparse] and [noparse]http://www.domain.com[/noparse] are different pages on your website. The proof is in the PR (Page Rank). Let's take a look at a screenshot of [noparse]http://wikipedia.org[/noparse]. As you can see below, it shows a Google Page Rank of 7.

    [​IMG]


    Now let's look at [noparse]http://www.wikipedia.org[/noparse]. As you can see in the screenshot, it shows a different Page Rank; a Page Rank of 8. It is viewed as a different page.

    [​IMG]

    Why should you care? A variety of reasons:

    1. When people link to your site, some will link to [noparse]http://domain.com[/noparse] and others to [noparse]http://www.domain.com[/noparse]. This causes your PR to be spread out over different pages instead of just one. The prevailing wisdom (I don't believe it, but that's an article for another time) is that a proper 301 redirect will cause the links that are pointed to [noparse]http://domain.com[/noparse] to be counted as pointing to [noparse]http://www.domain.com[/noparse].

    2. Potential duplicate content penalties. Anytime you have the same content on two different pages, you risk incurring a "duplicate content" penalty. As Google says in their Webmaster Guidelines, "Don't create multiple pages, subdomains, or domains with substantially duplicate content." Now, Google is usually pretty good at canonicalization (the process of picking the best url when there are various choices) but a proper 301 redirect removes the guesswork and ensures the url you prefer to to be displayed is in fact displayed.

    3. Cookie issues. Depending on how the cookie domain is set, the two urls may have different cookies sent to them, which may produce inconsistent page content.

    4. Nice, clean navigation. One of the most important aspects of SEO is creating nice, clean navigation for the bots to follow. You might as well start at the index with a proper 301 redirect.

    5. Because everyone is doing it, including Google. If Google jumps off a bridge, so should you.


    How to setup a proper 301 redirect

    The process of setting up a 301 redirect on an Apache server is quite simple. How to implement one on a non Apache server is an article in itself. Please note that you must have mod_rewrite installed on your server for this to work.

    Step 1. Create a normal .txt. file and name it htaccess.txt

    Step 2. Cut and paste the following code (replacing "yourwebsitename" with your website's name:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yourwebsitename\.com
    RewriteRule ^(.*)$ http://www.yourwebsitename.com/$1 [R=permanent,L]
    Step 3. Save the file and upload it via FTP to the root folder of your website.

    Step 4. Rename the file to .htaccess

    Upon submitting the name change, the .htaccess file will disappear in many FTP programs. That's normal. You can test to see if it is working correctly by typing in [noparse]http://yourdomain.com[/noparse] and checking if it automatically changes to [noparse]http://www.yourdomain.com[/noparse]

    Some people prefer to redirect [noparse]http://www.domain.com[/noparse] to [noparse]http://domain.com[/noparse] because they hold the opinion that www is deprecated. You fine folks can use this code instead:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.yourwebsitename\.com
    RewriteRule ^(.*)$ http://yourwebsitename.com/$1 [R=permanent,L]

    Share This Article

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.