As you have recently seen some websites just as Twitter do not use the “www” extension in their URL. This article is for those of you wondering whether or not you should choose the http://yourdomain.com or http://www.yourdomain.com and describe the difference between the two.

Say What?
The www and non-www are not the same in the search engine perspective. Many times in today’s search engine world they can result in duplicate content when being indexed if one is not redirecting the visitors to the other. Since search engines will only index one version of the website, you want to make sure that they are indexing the correct one. It is also very important to make sure that all your inbound links are using the preferred version. Say for example if you prefer the www.yourdomain.com you want to make sure that your inbound links are pointing to “www” version and not the non-www.

How do I choose which one?
First step is to find out your website ranking and how the search engines have indexed your website. Simply open your browser and head over to Google and type in “site:yourdomain.com”. For this example we have picked twitter.com. As you can see based on our search, Google has indexed the non-www version of Twitter. Next you might want to head over to Yahoo! Site explorer and get an idea of the inbound links count by performing the same search as we had just done on Google. Clearly, the non-www is the winner again.

Don’t forget the index.html, default.html, index.php etc. as those versions of your site might also be lurking around. You want to make sure that your index is your www.yourdomain.com or yourdomain.com.

How Do I Fix This?
You can easily fix all of this by performing a couple of the following steps. We will show you a few different steps that can help you by using .htaccess redirect.

Redirect WWW to Non-WWW

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example.com
RewriteRule (.*) http://example.com/$1 [R=301,L]

Redirect Non-WWW to WWW

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Redirect yourdomain.com/index.php to yourdomain.com

Options +FollowSymLinks
RewriteEngine on
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /.*index.php HTTP/
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

Google Webmasters
Head over to Google webmasters tools: www.google.com/webmasters/ – and set your preferences for your choice of www or non-www version. Once you login click on your domain name (we’ll assume you have it already setup). Then click on Site Configuration and then on Settings. You will see “Preferred Domain” section that lets you choose which one you want Google to use for this domain. Note that Google will not allow you to use this feature if you don’t have both the www and non-www verified, so make sure that you verify both your www and non-www versions of your site.

That’s all folks. If we can help you feel free to drop us a line or give us a buzz. Thanks for reading.