Remove the “www” from your URLs

April 21st, 2010

Remove the "www" from your URLsAs for as simple web site optimization tips go this is probably one of the more basic of those and should deffinately be considrede when working on any type of web site. You may or may not be aware of it but it is possible to access your web site using two distinct URLs. The first is by including the “www” and the section is leaving it out.

For example, this site can be accessed either via http://www.wmtutorials.com or via http://wmtutorials.com – both of which point to the exact same place.

When it comes to search engines it is possible and quite likely that they will see those two different urls as being completely different sites. This means that in the eyes of the search engines there are two copies of your site meaning two copies of all of your content. This may have an effect on the duplicate content rules which these search engines use and therefore could make a difference to your ranking.

More specific to Google, having two seperate URLs means that PageRank will be split between them. Google has absolutely no idea that they are in fact the same site meaning it’s very likely that each of them will be assigned a seperate PageRank value.

The solution is simple and only takes a minute or less to implement. Start by creating an empty file at the root of your web site called “.htaccess” and copy and paste in the following code snippet. If this file already exists simply copy and paste this code into the very top of the file above anything else.

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

Now before saving you need to replace every instance of “wmtutorials.com” in the above snippet to whatever your sites domain name is.

And that’s all there is. Now, when you visit your site using the “www” version you will automatically be redirected to the other version without even noticing. From now on with this simple htaccess rule in place search engines will see your site as being just one.

If however you’d like to go the other way you could always add the www into your URLs.

Add your comment