redirecting all possible hostnames to one using mod_rewrite


SEO experts claim that having multiple hostnames point to the same site will result in lower rankings for that site. It's common to see sites accept both "" and "".

I have no idea if this is true, but it makes a bit of sense, so why take the chance.

I want to direct everyone to "" regardless of what they type in, with one exception. I want to allow for a hostname for my own devious purposes. This is what I'd put in the mod_rewrite section of my .htaccess or httpd.conf file:

  RewriteCond %{HTTP_HOST} !^
RewriteCond %{HTTP_HOST} !^
RewriteRule (.*)$1 [R=301,L] 

This tells Apache that if the hostname is not "" *and* it is not "" then make it

For detailed info on Apache mod_rewrite, read the official documentation .  

That was easy.