Matt's Blog

Matt’s Blog Gets Class B Compliance

June 24th, 2007 at 4:48 PM (17 years ago) by Matt Freedman

I have just made it so that all traffic going to will be silently redirected to Which makes Matt’s Blog a Class B (the preferred class) in‘s books.

If you’ve never heard of before, it’s basically a campaign trying to raise the fact that www. is/should be deprecated. They have 3 “ranks” or “classes”. Class A, B and C.

Class A All traffic to and is accepted, and no redirect happens.
Class B The preferred class. All traffic to is silently redirected (301) to
Class C The hardcore class. Traffic to is denied and the user can only access the site through This class is not recommended.

Most hosts default their DNS to Class A. Where all traffic to and is accepted. The problem with Class A is that Search Engines might penalize you for having duplicate content (because you have the same content on and and you might end up with Search Results with and without the “www.“. You could even have 2 different PageRanks for your main page, depending on if you check with www. or no-www. Google allows you to define which domain you would like to show up in their Search Results. You can do this through Google Webmaster Tools. But, Google is only 1 of the many Search Engines.

So, how can you redirect to Well, it’s actually quite simple. This way will only work on Apache servers with mod_rewrite enabled. First, create a file (or open it, if it already exists) in your site’s root called .htaccess (including the period, but nothing before the period). Then, place this code in it (replace domain\.com with your domain name, make sure you escape the period):

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

Let’s go over that code now.

RewriteEngine On simply tells Apache to allow you to use the mod_rewrite module (make sure it’s installed, first).

RewriteBase / makes sure we’re working on the root domain.

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC] tells the Server to see if the URI requested has the domain The [NC] tells it that it’s case-insensitive.

RewriteRule ^(.*)$ http://domain\.com/$1 [R=301,L] says that if RewriteCond is true to silently redirect the user to ^(.*)$ holds the value of what was after the original URI. $1 then makes sure that they’ll be redirected to the same page they requested. [R=301,L] will tell the User-Agent (browser, or bot) that the redirect type is 301 Permanent and and L tells the Server that it’s the last rule.

Note: If you’re using WordPress for the site in question, the above code must go above WordPress’ redirect stuff. So place it somewhere above # BEGIN WordPress.

Then, save the file and upload it to your site’s root. Now, all that’s left to do is to get Validated by Go here to do that. Your site should now be a Class B!

That’s it, your site is now even more Search Engine friendly.

Get it? Got it? Good!

One Response to “Matt’s Blog Gets Class B Compliance”

  1. Matt’s Blog » Blog Archive » WordPress 2.3
    Matt’s Blog » Blog Archive » WordPress 2.3 says:

    […] There’s been some cool changes to the Permalink system, go can see the changes in the this comment on the Trac ticket. Including enforcing either www. or no www. […]

Leave a Reply

Quote selected text

Leave the following field empty: