With or without www.

If you have a top level domain name, probably you have your blog set up to work from www.blogname.com and blogname.com too. (In case not, you define should!) But do they display the same site? Are you sure? If the URL is different, some log analyzers, even search engines might think that they are actually two different sites - regardless of the exactly same content. But with a small .htaccess rule, you can redirect your visitors from one to another, while keeping all your old links working too.

Technorati Tags: ,

The concept is to create a redirect with a regular expression, telling your webserver to change all URLs starting with www.blogname.com to blogname.com, while keeping the rest of the URL untouched. The actual .htaccess file is pretty simple, all you have to do is change the two URLs from blogname.com to your blog's address:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^blogname\.com
RewriteRule ^(.*)$ http://blogname.com$1 [L,R=301]
</IfModule>

If you have problems making this work, check our previous posts on .htaccess tricks.

April 24, 2006

Submit to del.icio.us | Digg | Furl | reddit | Y! MyWeb | comments (0)

Post a comment