www or no www in your URL?

Here’s a quick howto on sending visitors to your preferred hostname. The primary reason for this is so that the search engines don’t see www.domainname.com and domainname.com as two identical sites. If they do, one of them will be “penalized” as containing duplicate content. The penalty is that one of the sites will be moved to the supplemental results. This also helps with incoming links so that all of your pages get their deserved “link juice.”

Three simple lines in your .htaccess file can accomplish this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.alt-j.com$
RewriteRule ^(.*)$ http://www.alt-j.com/$1 [R=301]

What this does is checks and anytime the hostname doesn’t match www.alt-j.com, it redirects to the same url on www.alt-j.com. For example, visiting http://alt-j.com/someotherpage will automatically redirect you to http://www.alt-j.com/someotherpage. Since it’s a 301 redirect, all link juice goes with it.

The method I have above will also work for other non-www hostnames (i.e. – ww.alt-j.com, where someone forgot a ‘w’)

Comments are closed.