Dream Systems Media Blog

[dreem sis-tuhms mee-dee-uh blog]
The blog of Dream Systems Media, a trend setting Internet marketing firm, with locations in Utah and Arizona

Home > SEO > 301 Redirect and .htaccess Tips

Mat Siltala 301 Redirect and .htaccess Tips

January 29th, 2009
By Mat Siltala Leave a comment

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!

Share and Enjoy:
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • NewsVine
  • Propeller
  • StumbleUpon
  • Technorati
  • TwitThis
  • Yahoo! Buzz

SEO , ,

  1. bob unitt
    April 15th, 2009 at 02:25 | #1

    Hi. What are non-www’s?

  2. April 15th, 2009 at 17:53 | #2

    Hi Mat,

    I have a question about 301 redirects I have used on my site with the help of a plugin. I have made them no-follow but I am unsure if I am doing the wrong thing. I would really appreciate your advice.

    I have ‘Debt Guides’ on the index bar with a list of the guides, all the sub-domains, listed as 301 redirects.

    In my Google Webmaster tools, it shows as ‘warnings’. Should I remove these 301 pages?

    I am not looking for a link, but I am looking for your advice, so if you would prefer to email me direct and not post my comment that’s ok with me.

    James

    James Williams’s last blog post..A Debt Management Plan Can Help You Get Out Of Debt

  3. April 18th, 2009 at 04:26 | #3

    Hi Mat,

    Thanks for that info.

    Have been meaning to do a couple of redirects for a while. This is the first straightforward explanation I’ve found.

    I have one question, is the order of the code on the htaccess file important? For example I have a few IP addresses from habitual spammers blocked on my file. I’m going to redirect my non www’s and put in a couple of redirects, should they go at the beginning of the file or doesn’t it matter?

    Dave.

  4. April 27th, 2009 at 06:47 | #4

    If you had http://www.site.com/index.html and also http://www.site.com/index.php with both pages containing similar content – could this result in Google dropping your site down the listings. I was #1 for many different queries but now I am lucky to be in to 100. There was very little change to the site and this may be the reason for some of it – I am guity of that one!

    Shane’s last blog post..ShaneMcDonald.com

  5. June 29th, 2009 at 21:37 | #5

    Good article. Thanks for the tip on #301-redirect, Mat.

  6. Spammy Name
    May 8th, 2010 at 09:11 | #6

    You helped me a lot with the 301 redirect code, Mat. I used it in my .htaccess file and it works like a charm.

  1. April 8th, 2009 at 10:42 | #1
  2. April 10th, 2009 at 10:53 | #2
  3. April 13th, 2009 at 16:29 | #3
  4. April 15th, 2009 at 04:23 | #4
  5. August 9th, 2009 at 18:55 | #5
  6. August 25th, 2009 at 18:58 | #6
CommentLuv Enabled
HOME SERVICES ABOUT CONTACT US REQUEST QUOTE SITEMAP PRIVACY © 2010 Dream Systems LC.