htaccess Tip. www vs non www. URL Rewriting with Mod Rewrite

I know this isn’t the kind of site you normally would see this type of article! I had to share this though.

Last week my page appeared on Googles first page for 2 keyword phrases. Then all of a sudden it dropped all the way to the 7th page. As you can imagine I was confused and frustrated. What in the world happened? For the life of me I couldn’t figure out what I did. Then I dug deep and searched long an hard for a possible explanation. So like most of my SEO adventures normally begin I asked around in several forums as to why this happened. No one really could give me an honest answer.

I did get a one answer however that intrigued me. I posted to Google Forums this question:

Hi My site is fairly new http://www.thesafestcandles.com

For the past week I was on the first page of Google for 2 keywords. Today however I’ve dropped to the 7th page? I’ve done nothing new to the site? Can someone explain why?

Here is the answer one person gave me:

Hi Shawn,
Consider doing 301 redirects to one home page and not four of them, http://thesafestcandles.com/ http://www.thesafestcandles.com/ also drop the duplicated site again by 301 and let WMT know which is your preferred domain.
I typed int the address bar of my browser to see what they were talking about and sure enough my site came up 2 different ways. This from what I know now is not good. This will not get you banned from google but as you read on you will see it does hurt your ranking.

I had used 301 redirects for missing pages but never a 301 rewrite mod. I wasnt sure what this person meant at first so I researched 301 redirects for domains and came up with this htaccess rewrite mod code

————————————————————-

RewriteEngine on
rewritecond %{http_host} ^thesafestcandles.com [nc]
rewriterule ^(.*)$ http://www.thesafestcandles.com/$1 [r=301,nc]

————————————————————-

For those of you not familiar with htaccess look here

What this does is everytime someone types in “thesafestcandles.com” into the address bar it redirects to “www.thesafestcandles.com”. It fixes the duplicate content. I applied this last night within hours I was back on the front page of google for my keywords!

I hope this helps some of you out there. If this does help you please support me and take a look at my scentsy wickless candles :)

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>