877.873.9298
  • 301 Redirect and .htaccess Tips

    SEO  

    Jan 29 2009

    A friend of mine who is just starting out (Internet business) was asking me the other day about 301 redirects, www’s vs non-www’s in domain and the .htaccess file and how it all relates to what I do and SEO etc.  Because of that, I wanted to post it here on this blog.  I have posted this information in other places before, but wanted it here for any of the Dream Systems Media readers to have access to it.

    For anyone who is serious about search engine optimization knowing about 301 redirects is a MUST.  I searched and searched all over for the “bottom line-tell me how to do it” examples of the 301 redirects and found the information confusing.

    What you need to know, and NOTHING more!

    First: The code to get your non www’s always redirecting to the www’s is as follows:

    Here’s the code:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^yourdomain.com
    RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

    (Make sure your Apache installation has mod_rewrite enabled.)

    As long as your Apache installation has mod_rewrite enabled then you should be able to use this fix on almost any host.

    Second: If you have any old page urls that are being replaced by new search engine friendly ones, but do not want to lose your page rank then here’s the code for that:

    redirect 301 /old/oldurl.html http://www.newurl/new.html

    MAKE SURE you DO NOT include the http://www.whatever.com  ONLY USE whats after the .com starting with the / or it will not work!  Also make sure to only put ONE space in between everything!

    There you go!  That is as simple as it gets…or at least as I can make it!

    Remember why we do the 301 redirect:

    Mainly for Google.  Google does not like a bunch of error pages and if you have alot of 404 error pages that do not exist anymore (maybe after doing a redesign, or introducing new SEF naming conventions) then its harder for Google to crawl and you can lose the page rank the page has.  With the 301 redirects you do not lose PR and you will not have to worry about duplicate content issues with your www and non www’s.  That alone is worth doing it!

    A side note it might be a great idea to have your web designer create a custom 404 error page so it directs people to something useful so you are not losing traffic just in case a page is forgotten in this process. I have found that people are more willing to give the site a second chance when they see a custom 404 error page that helps lead them to the place they might have been looking for!