Internet Leaders Needed Worldwide For A Booming New Opportunity Launching Soon
 




Get Reviewed by this Blog for only $500
DealDotComTTZ MediaGoogle Adsense
Pepperjam NetworkBidvertiser
Text Link AdsKonterra

Most websites can be reached with two addresses. One address has the www in it, like http://www.johnchow.com, while the other address has the www missing; http://johnchow.com.

From a SEO standpoint, it is better to pick one domain format and stick with it. This way you don’t have Google giving separate PageRank for two URLs that point to the same page. The easiest way to do this is by logging into your Google Webmaster Tools account and setting a preferred domain.

The preferred domain is the one that you would liked used to index your site’s pages (sometimes this is referred to as the canonical domain). Links may point to your site using both the www and non-www versions of the URL (for instance, http://www.example.com and http://example.com). The preferred domain is the version that you want used for your site in the search results.

Once you tell us your preferred domain name, it may help us determine PageRank for your site more accurately.

Adding a 301 Redirect

After you set the preferred domain, you should force everyone to use this domain with a 301 redirect. You do this by editing your root .htaccess file. I want everyone visiting John Chow dot Com to do so with the www in the URL. To force this, I open my .htaccess file and enter the following codes:

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

You will need to replace johnchow.com with your site URL. What the above does is redirect all johnchow.com to www.johnchow.com. How does this help with search ranking?

By maintaining one preferred domain format, you ensure linking consistency. If you have 10 sites linking to your article with a www and another 10 sites linking without the www, you present Google with two pages, which will not receive the same weight as 20 sites linking to the preferred domain. The above .htaccess code will ensure that everything goes to the domain format you want.

Note - the .htaccess redirect works only on Linux servers with the Apache Mod-Rewrite module enabled.

Find out what I am doing right now by following me on Twitter! If you like this post then please consider subscribing to my full feed RSS. You can also subscribe by Email and have new posts sent directly to your inbox.

Make Money Online with John Chow's Ad Network - Join TTZ Media Now!
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Here's A Few More Related Posts

  • Am I The Only One Who Named a Child This Way?
  • Google Tells Domain Tasters To Eat Cake
  • How Much Is Your Domain Name Worth?
  • Renewing Domains? Here Are Some GoDaddy Coupons
  • PickyDomains Names Your Domain

    RSS feed | Trackback URI

    52 Comments »

    Comment by Jane
    2007-01-30 23:09:52
    MyAvatars 0.2

    Good information especially for those trying to get ranked by Google (should be everyone!). The only bad news is I don’t have the Linux servers :(

    Comment by Matthew Subscribed to comments via email
    2007-01-31 01:45:54
    MyAvatars 0.2

    This can be done in Windows a few ways.

    1st by installing a rewrite DLL (can be pricey or free with restrictions to X amount of page loads or something.

    or

    2nd Coding it in to the header of your pages to switch the page to the www version (not sure if thats a 301 or 302 though. I have never tested this way).

    3rd Opening up IIS and creating 2 websites (www.domain.com and domain.com) and then setting 1 to redirect to the other by specifying a permanent redirection for this resource.

    With all 3 of these there might be something custom to write… but with rewrite on NIX you also need to manually write the rules too, so either way there is work to do.

    Comment by Jane
    2007-01-31 11:41:12
    MyAvatars 0.2

    SAWEEEEET! I’ll look into it. Thanks for the info Matthew!!! I’ll let you know how it turned out.

     
     
     
    Comment by inspirationbit
    2007-01-31 00:51:53
    MyAvatars 0.2

    That’s a very useful piece of information - thank you, John. It’s something I was wondering about in the back of my mind, but it never surfaced for an investigation :-)

     
    Comment by Nate W.
    2007-01-31 01:12:28
    MyAvatars 0.2

    Very useful tip. I have been using http://natewhitehil.com, because I think the www adds too much typing to my direct address. Is there a particular reason you prefer using the www, John? Or is it simply a matter of preference?

    Comment by John Chow
    2007-01-31 10:09:30
    MyAvatars 0.2

    It’s more preference than anything else. I feel an URL should have www because it tells this URL points to the World Wide Web. There are other prefaces we can put in front of our domain that would mean something else. Like http://ftp.johnchow.com or mail.johnchow.com. I want make sure they go to http://www.johnchow.com :)

     
     
    Comment by Cory OBrien
    2007-01-31 01:26:51
    MyAvatars 0.2

    I prefer the www just because I feel like that is what most people would type if they were to type in your address.

    Comment by Jane
    2007-02-01 00:33:41
    MyAvatars 0.2

    I agree. I jut think that the majority of people that are using the internet have come to know it as the “world wide web.” It’s second nature to put http://www. in front of any domain.

     
    Comment by Kalle
    2007-02-10 05:24:50
    MyAvatars 0.2

    Do you think? I have the opposite opinion. It is much more easy to write johnchow.com than http://www.johnchow.com, and I think most of the internet users write without http://www.

     
     
    Comment by Leftblank
    2007-01-31 02:07:43
    MyAvatars 0.2

    Nice tutorial, I’ve been using it for a while already though. A little note; that .htaccess works like a champ on Apache on Windows or OS/2 or so as well, it’s not depending on Linux as platform ;)

     
    Comment by Allen.H
    2007-01-31 02:34:56
    MyAvatars 0.2

    Nice tip John, since there’s a bit of controversy on whether with/out the www is better I’ve doing a test for 2 months now…although I think there is no (significant) difference between the two SEO-wise.

    Allen.H

    Comment by Jeff
    2007-02-02 01:05:46
    MyAvatars 0.2

    Until the debate of which is better is settled.. we may as well set it to just one of them for consistency.

     
     
    Comment by goddoll
    2007-01-31 02:39:35
    MyAvatars 0.2

    Ok, so I’m guessing that explains why there are a couple different sites on technorati’s top 100 twice?

     
    Comment by Chris
    2007-01-31 02:52:11
    MyAvatars 0.2

    My understanding of it is that that without WWW is the correct form, and the true URL of your site.

    The WWW is unnecessary.

    Just being contrary John? ;-)

    Comment by Matthew Subscribed to comments via email
    2007-01-31 03:57:21
    MyAvatars 0.2

    Technically yes “domain.com” it is the correct form. When you buy a domain you do not buy http://www.domain.com. You buy domain.com. WWW is just an alias with an A record in DNS. You might notice some larger sites have http://www.domain.com and www2.domain.com indicating possibly a different server for a simple load balancing solution.

    WWW has caught on though over the years and a number of people I know always enter www before a domain name. Some even get a bit confused when I tell them a domain name over the phone without http://www. They always ask if they need to add www to the front of that.

    At the end of the day I dont think it really matters which you specify as long as you stick with 1 format or the other on your site and 301 any other possibilities to the 1 format… be it a www record or second domain.

     
     
    Comment by Tam Denholm
    2007-01-31 03:15:11
    MyAvatars 0.2

    You can also use PHP to do it. Personally i think domains look neater with the www subdomain. Its also very easy to do it with wordpress. At the top of your index.php file just add this:

    if(!strstr($_SERVER['HTTP_HOST'], ‘www’)){
    header(’Location: http://www.dreadblog.com/‘);
    }

    What it does is check for the a www in the address requested and if it doesnt exist it forwards you to the address with the subdomain. Similarly you could do the same if you wanted to not include the www:

    if(strstr($_SERVER['HTTP_HOST'], ‘www’)){
    header(’Location: http://dreadblog.com/‘);
    }

    You could also extend that to add the pages and query strings aswell.

    Comment by Martin
    2007-01-31 09:55:12
    MyAvatars 0.2

    Thanks for the comment. It works great.

    I did the non-WWW version.

     
    Comment by Aris
    2007-01-31 22:22:21
    MyAvatars 0.2

    This one works fine. First, I forgot the php brackets and the code appeared on top of the page. Once I added the code, it works fine for both Fairfox and IE. Thanks.

    Comment by Aris
    2007-02-01 05:56:32
    MyAvatars 0.2

    Oops, Houston, we have a problem. :-)

    After adding the code to add ‘www’ to the URL, now, when I click to read “More”, it didn’t bring up the whole posting.

    Any suggestion? Which php file do I need to edit?

    Thanks.

     
     
     
    Comment by Ryan
    2007-01-31 06:32:07
    MyAvatars 0.2

    If Google allows you to set the preferred name then why aren’t they giving the same weight to the pages? I tell Google they’re the same, so why are they then treating them differently?!

     
    Comment by Marc
    2007-01-31 06:47:38
    MyAvatars 0.2

    This is some of the best advice you can give to new webmasters. It’s a common issue that’s very easily resolved.

    Be sure to set up the redirect though. While the Google Webmaster Tools setting is helpful, it will only work for Google, so don’t skip part two.

     
    Comment by Cameron Wilmot Subscribed to comments via email
    2007-01-31 07:36:44
    MyAvatars 0.2

    Good tip John but do you think it actually makes much difference?

    Comment by Allen.H
    2007-02-01 14:44:42
    MyAvatars 0.2

    Of course it does! John explains it the best here:

    “If you have 10 sites linking to your article with a www and another 10 sites linking without the www, you present Google with two pages, which will not receive the same weight as 20 sites linking to the preferred domain.”

    Now that’s a massive difference in the long run!

    Allen.H

     
     
    Comment by Jonathan Brazil
    2007-01-31 08:02:06
    MyAvatars 0.2

    Like this tip a lot John. It’s been something that has started to bug me in recent times as people either have badly configured their apache rewrites or worse still. Entering the domain.com gives one site and http://www.domain.com gives another. There have been countless cases when I’ve had to point people in this direction - let’s hope they’re reading your blog now! :)

     
    Comment by Al Davies
    2007-01-31 09:09:13
    MyAvatars 0.2

    Definitely make sure to back up your .hta before making any changes to it. You might want to back up your blog db also while you’re at it.

    Comment by Nomar
    2007-02-01 01:17:16
    MyAvatars 0.2

    Yes, I made the mistake to, when i first experimented with .htaccess

     
     
    Comment by Kenny
    2007-01-31 09:11:15
    MyAvatars 0.2

    Good write-up. I wrote about the exact same topic just prior to you posting it up so hopefully readers that stumble on my blog don’t think that I am stealing content ;)

     
    Comment by Patrix
    2007-01-31 11:57:35
    MyAvatars 0.2

    Thanks for this tip, John. I was looking for a quickfix solution. It worked like a charm.

     
    2007-01-31 12:33:29
    MyAvatars 0.2

    [...] found a simple solution on John Chow’s website. You have to modify your .htaccess file and add the following code: RewriteEngine OnRewriteCond [...]

     
    2007-01-31 12:36:57
    MyAvatars 0.2

    Wicked good info.

    Always appreciated.

    Thx,

     
    Comment by dangerou
    2007-01-31 15:27:11
    MyAvatars 0.2

    John - can you post the code to do the same thing in the other direction? (To make it exclude the www)

    Comment by Nate W.
    2007-01-31 20:02:41
    MyAvatars 0.2

    I also would this… can anyone else please try rewriting it for us? Thanks!

     
    Comment by Kenny
    2007-01-31 21:49:29
    MyAvatars 0.2

    The following code will do it backwards and will drop the www from the domain name:


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

     
    Comment by Kenny
    2007-01-31 21:50:47
    MyAvatars 0.2

    Oops, forgot to add, you’ll have to change the domain name from the person I found the code from to your own domain name.

    Comment by Nate W.
    2007-02-01 22:05:22
    MyAvatars 0.2

    Thanks for the help, Kenny! It works like a charm!

     
     
     
    2007-01-31 15:59:44
    MyAvatars 0.2

    [...] John Chow Like this article? Subscribe to the RSS [...]

     
    Comment by Investorblogger
    2007-01-31 16:03:39
    MyAvatars 0.2

    Yes, good tip, John. I found that dreamhost also allowed me to do that! So I set it up like that, otherwise I wouldn’t have realized. Some of my websites have two different PRs. If I added them together, some of my websites would have a PR6. Unfortunately, I don’t think PR is quite that simple!

    Comment by Investorblogger
    2007-01-31 16:06:09
    MyAvatars 0.2

    Actually, the PHP code tip was excellent. I will ad that to my website soon. Just hope I can hack the php on my blog without screwing up the blog completely.

     
     
    Comment by Nomar
    2007-02-01 01:16:18
    MyAvatars 0.2

    I already did that with .htaccess

    but I am also going to set it in google.. thanks for the extra info

     
    Comment by uncle sha
    2007-02-01 01:16:25
    MyAvatars 0.2

    I never thought about this, thanks for the tip, great one!

    I’ve set it up easily on my server … cool!

     
    Comment by TJP
    2007-02-01 05:46:28
    MyAvatars 0.2

    I noticed a couple of my links were showing up w/o the www, but didn’t know how to fix it. Thanks for the info.

     
    Comment by Aris
    2007-02-01 06:34:04
    MyAvatars 0.2

    Since I have trouble in reading the ‘more’ part after forcing the URL to add ‘www’ using Tam Denholm’s code shown above, I have reverted it back to Tam’s ‘no www’ code and so far it works fine. I think I should keep it without ‘www’. At least, last night when I changed the URI by adding ‘www’ in my comment here, it didn’t go through. My guess was, I have used no www in my URI so far and adding www to my URI means a new URI to this blog.

     
    Comment by Max Subscribed to comments via email
    2007-02-01 14:02:31
    MyAvatars 0.2

    Does Technorati have a way of picking up both the www domain and the one without the www? What about Alexa?

    Comment by Jeff
    2007-02-02 01:07:17
    MyAvatars 0.2

    good question. anybody know the answer? i’d like to find out.

     
     
    Comment by Nick Witkoski
    2007-02-01 20:25:20
    MyAvatars 0.2

    Thanks for this tip as well john, I will have to try this and the favicon thing, and still try to work in some of the pluggins i havnt had a chance to add.

     
    Comment by Ryan
    2007-02-02 06:51:23
    MyAvatars 0.2

    If you’re running Wordpress butyou aren’t using Apache and/or don’t want to edit .htaccess, then there is a plugin that will redirect for you.

    It’s called WWW Redirect and can be found at:

    http://www.justinshattuck.com/wordpress-www-redirect-plugin/

     
    Comment by ketyung Subscribed to comments via email
    2007-02-04 19:40:24
    MyAvatars 0.2

    Nice tip john, I’m wondering if this affects the pr ? I have a PR4 for Techchee.com w/o www, but getting only PR2 with www, I’ve done for the .htaccess and now access using w/o www will be forwarded to the one http://www. Will this method balance up my PR or make it drop to 2?

     
    2007-02-05 22:07:39
    MyAvatars 0.2

    [...] have the Apache Mod-Rewrite module enabled. (which Bluehost does). For more information, check out John Chow, who wrote up a great article on this [...]

     
    Comment by Kalle
    2007-02-10 05:22:16
    MyAvatars 0.2

    Thanks for the great information :)

     
    2007-02-13 16:09:55
    MyAvatars 0.2

    [...] Setting The Preferred Domain [...]

     
    2007-02-18 12:17:41
    MyAvatars 0.2

    [...] Reference: John Chow - Setting The Preferred Domain [...]

     
    Comment by Robert
    2007-02-19 06:44:15
    MyAvatars 0.2

    For WordPress, there is also the Enforce plugin. Enforcers whatever you set for your domain under General Options.

    http://txfx.net/code/wordpress/enforce-www-preference/

    Works perfectly with WP 2.1.

     
    Name (required)
    E-mail (required - never shown publicly)
    URI
    Your Comment (smaller size | larger size)
    You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.