Have You Set Your Preferred Domain?

39 Comments April 11, 2007 / Posted in Blog Development, SEO/SEM

Have You Set Your Preferred Domain?

All web sites can be reached from two URL addresses: one with the WWW and the other without the WWW. For example, you can reach this blog by typing in http://www.natewhitehill.com and also http://natewhitehill.com.

However, it is imperative that you pick one address and stick with it for maximum search engine results and PageRank. If, generally, you use the version with the WWW and someone links to your site and they do not include the WWW, the search engine spiders will index that link as a separate domain from the one with the WWW.

For example, my good buddy, Matt from Take More Risks, recently had 2 separate PageRanks for his blog. His blog URL with the WWW had a PR 3, while the URL without the WWW had a PR 2. In other words, Google indexed that same domain as 2 separate ones. Most likely, he could have achieved a higher PageRank if he had set his preferred domain earlier. If you don’t quite understand PageRank, read this article about the upcoming PageRank update.

Which Preferred Domain Should You Choose?

Well, first you need to pick which version you rather use. I chose to go without the WWW, so my preferred domain is http://natewhitehill.com. There is no one reason to pick one instead of the other - it is purely a matter of preference. I chose to go without the WWW because having a longer domain name (13 characters, in my case), I thought it would make it easier for people to remember the URL if they just saw the natewhitehill.com and not the www.natewhitehill.com. John Chow, on the other hand, chose to use the WWW. Just to reiterate, there is no definitive reason to pick one over the other.

Setting the Preferred Domain

After you choose your preferred domain, you must now create a 301 Redirect to forward one address to the other. If you are hosted on a Linux server, you do this by editing your .htaccess file. You may first need to create one and to do this you must:

1) Create a simple text file and name it .htaccess
2) Modify it with the proper code (details below)
3) Upload it to the root of your server

Here is the code you should use if you want people to redirect from non-WWW to WWW:
(for example, if someone types in http://domain.com, it will forward to http://www.domain.com)

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

Here is the code you should use if you want people to redirect from WWW to non-WWW:
(for example, if someone types in http://www.domain.com, it will forward to http://domain.com)

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^.*$ http://domain.com%{REQUEST_URI} [R=301,L]

In both cases, make sure to replace “domain” with the URL of your domain.

By setting a preferred domain you are ensuring that Google and all the major search engines will only index links from one domain. This will help your PageRank the next time around and also you receive more weight in current search engine rankings.

If you have not set your preferred domain yet or have been putting it off, DO IT NOW. You will thank me later when you get a higher PageRank.

39 Comments... What do you think? Subscribe via RSS

39 Comments... What do you think?


  1. BriNo Gravatar
    BriNo Gravatar said on April 11th, 2007 at 5:49 am

    Done! Thanks for the heads-up, Nate. I appreciate the sound advice.

  2. FrankNo Gravatar said on April 11th, 2007 at 5:52 am

    I’ve been thinking about this for a while but your post has spurred me into action. I’ve now set it on the server and then gone into Google Webmaster tools and set the preference to the same. Hopefully they won’t penalize me for changing this right before a PR update. Cheers.

  3. Ryan J. ParkerNo Gravatar said on April 11th, 2007 at 6:36 am

    Why yes, yes I have. I always use http://WWW. I have WordPress-MU setup on one website, and it doesn’t work well with WWW, so that’s the only one that isn’t http://WWW.

  4. Ryan McDonnellNo Gravatar said on April 11th, 2007 at 8:26 am

    The same thing also applies to the default page for a site. The root, “/”, and “/index.php” or “/default.aspx” are considered unique URLs in the search engines. A similar rewrite rule can be added to 301 redirect all requests for the default document to the root of that folder.

    I covered how to do this with a WordPress blog a little while back on my blog:
    http://www.ryanmcdonnell.com/redirect-indexphp-to-with-wordpress/

    The rule looks something like this:

    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
    RewriteRule . / [R=301,L]

  5. Jane MayNo Gravatar said on April 11th, 2007 at 9:27 am

    Great piece of advice. I did this 2 months ago when I realized I was able to do so.

  6. Scot SmithNo Gravatar said on April 11th, 2007 at 11:12 am

    Good advice. Done this a while back actually.

  7. NatronNo Gravatar said on April 11th, 2007 at 1:20 pm

    Very good suggestion. I use this type of code on all of my content sites also.

  8. mikeNo Gravatar said on April 11th, 2007 at 3:13 pm

    You would expect that since www and non-www sites display the same, a search engine would be able to know that. I can’t think of any time when http://www.example.com and example.com would ever be different.

  9. Nate WhitehillNo Gravatar
    Nate WhitehillNo Gravatar said on April 11th, 2007 at 3:20 pm

    Hey Ryan - great tip! Thanks for bringing this up! :)

  10. FrankNo Gravatar said on April 11th, 2007 at 3:38 pm

    Funny you should say that. Ja Kel has this very setup with his wife’s blog. It’s pretty unusual but it seems to work for them.

    http://jakeldaily.com/two-blogs-one-domain-double-power/

  11. ShaneNo Gravatar said on April 11th, 2007 at 4:45 pm

    Nate,

    I notice that if I put www in front of this posts url … it redirects to your homepage … hmm. Wouldn’t it be better to redirect to the same address without the www? Not that I have a clue if it’s better or how you would do it … just some fuel for the discussion here

  12. Nate WhitehillNo Gravatar
    Nate WhitehillNo Gravatar said on April 11th, 2007 at 5:45 pm

    Hey Shane, yeah I just noticed that. Frankly, I have no idea how to fix it so that if someone does have the full post URL and types it WWW it redirects to the post without the http://WWW. Thankfully, most people will copy and paste a post URL instead of typing it out long hand. Interesting point, however.

  13. ShaneNo Gravatar said on April 11th, 2007 at 7:22 pm

    I’m just thinking that if you link to your own posts or other people have links to certain posts using www, and you change your preferred domain to non-www, those links are now wrong.

    And it’s only a problem if you change this mid-stream in a site’s life after some links have been established.

    Guess I’ll look into it a bit more and make a decision,
    thanks Nate

  14. Nate WhitehillNo Gravatar
    Nate WhitehillNo Gravatar said on April 11th, 2007 at 7:53 pm

    You are correct that if I change my site back to WWW the links will be dead. I guess I’ll just have to stick with non-WWW for my lifespan. Let me know if you find a way around the redirect for the individual posts.

  15. NatronNo Gravatar said on April 12th, 2007 at 6:40 am

    A 301 redirect will direct all the weight of the backlink to the target domain. Although there may be a time lapse before the weight is transfered, it will transfer. This not only works within a site, but also if you switch domains. Think of it as forwarding your mail to your new apartment.

    Forget about adding code to your .htacces and install this simple plugin: http://txfx.net/code/wordpress/enforce-www-preference/

  16. Ryan McDonnellNo Gravatar said on April 12th, 2007 at 10:28 am

    Can you post the contents of your .htaccess file? I’m thinking there might another rule that is causing this behavior. I’m using the same rule and individual posts are being redirected properly.

    My .htaccess looks like this:

    Options +FollowSymLinks

    # Redirect @ to www

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

    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
    RewriteRule . / [R=301,L]

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

  17. NatronNo Gravatar said on April 12th, 2007 at 10:33 am

    This may help, a little different…

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

  18. Nate WhitehillNo Gravatar
    Nate WhitehillNo Gravatar said on April 12th, 2007 at 5:19 pm

    Thanks for the code, Ryan. That is very helpful.

  19. Nate WhitehillNo Gravatar
    Nate WhitehillNo Gravatar said on April 12th, 2007 at 5:20 pm

    Thanks for the heads up on the plugin, that will simply things quite a bit for those not so technically savvy.

  20. NatronNo Gravatar said on April 13th, 2007 at 6:26 am

    best bet not to mess with .htaccess especially when the program is writing to it.

  21. ShaneNo Gravatar said on April 13th, 2007 at 9:25 pm

    Natron,

    Awesome.

    I try to keep plugins to a minimum, but I don’t know too much about .htaccess. I tried both your code and the plugin. They both work perfectly so I’m going to go with the plugin so I don’t overwrite the code accidentally.

    And thanks for starting the discussion Nate!

  22. TeamTutorialsNo Gravatar said on April 18th, 2007 at 4:59 pm

    I always wondered if there was any logic behind dropping the http://www.

  23. NatronNo Gravatar said on April 19th, 2007 at 8:09 am

    I would think that appending the “www” would be the best bet as most will link with the “www” added anyway, you have less links to 301 redirect. I hope Nate responds with his reasoning.

  24. coopNo Gravatar said on April 19th, 2007 at 1:50 pm

    this rocks.

  25. coopNo Gravatar said on April 19th, 2007 at 1:52 pm

    will this work if i do a mod rewrite to foward all Digg traffic to a mirror?

  26. Nate WhitehillNo Gravatar
    Nate WhitehillNo Gravatar said on April 19th, 2007 at 5:23 pm

    301 redirects work for directing any URL to any oher URL.

  27. Nate WhitehillNo Gravatar
    Nate WhitehillNo Gravatar said on April 19th, 2007 at 5:23 pm

    Only reason I got rid ot the WWW was so that it would be easier for people to visually remember my name from looking at the URL without all the WWW’s.

  28. NatronNo Gravatar said on May 8th, 2007 at 1:15 pm

    I prefer the fully qualified domain with the “www” as many editors will associate that as a link. That will be the only real reason I see.

  29. derekNo Gravatar
    derekNo Gravatar said on June 27th, 2007 at 4:40 am

    Curious if my domain is in a subdirectory, for instance I have a blog installed in a blog folder like http://www.mydomain.com/blog do I have to change the htaccess file to see the subdirectory or is it fine as is?

  30. NatronNo Gravatar said on June 27th, 2007 at 8:40 am

    You would need to place a .htaccess file in the root to redirect any traffic to the subdirectory. In the subdirectory you would also need a directive as given to append the “www”

  31. nsderekNo Gravatar
    nsderekNo Gravatar said on June 28th, 2007 at 9:20 pm

    Thanks thought I am not exactly sure what you mean by in the subidrectory you would also need a directive as given to append the wwww.

    Are you saying that I need to add the same code to another htaccess file in the subdirectory as well? Forgive my rookieness

  32. nsderekNo Gravatar
    nsderekNo Gravatar said on June 29th, 2007 at 8:37 pm

    Damn I wish I read all the comments earlier. That plugin works great for redirecting and that would work just as good as manual. Still like to know how to get it to work manually. I tried it but it would only redirect my main page in the root, anything that was in my subdirectory wouldnt do anything

  33. SNo Gravatar
    SNo Gravatar said on June 15th, 2008 at 9:25 pm

    The problem persists. I writed down code you proposed and uploaded it to the server with *.txt format. however, now, when trying to reach my site with WWW, 404 error accures… What shall I do?

  34. [...] Nate Whitehill reminds us to focus on a single preferred domain for better SEO optimization in his “Have You Set Your Preferred Domain?“. [...]

  35. managing your htaccess file for better search results said on April 13th, 2007 at 7:02 pm

    [...] Whitehill has a great post about choosing your preferred domain name.  Do you want the www or not?  Check out the article, it includes a tip that I recommend everyone [...]

  36. [...] I made the domain always point to http://2slice.com. If you want to find out how to do this, visit Nate’s blog. Whilst registering, i thought it would also be handy to grab the domain twoslice as i expect some [...]

  37. [...] I’ve spent considerable effort studying the effects of www and non-www recognition of blog URL’s; 301 redirects etc. I’ve found excellent resources through Matt at Take More Risks; Matt Cutts at Gadgets, Google and SEO as well as Nate at NateWhitehill dot com. [...]

  38. [...] and http://www.janemayblogs.com are active, and neither redirects to the other.  Definitely read Nate’s guide about the advantages of setting your preferred domain.  She’s got duplicate [...]

  39. [...] .htaccess code cited from Nate White Hill dot com [...]

Join the discussion by leaving a comment...

How do I change my avatar?

Go to gravatar.com and upload your preferred avatar.