root domain redirection: to

Date: 14 Jul, 2008
Posted by: admin
In: internet, web design & development|linux, open source & software|Search Engines, SEO & SEM

Bookmark and Share

I hate that .. when organisations (the biggest offenders I see appear to be the sites) don’t do their redirects properly.

I always just type the root domain, But for sites that I manage I choose “” to be canonical – mainly because in print it’s best to use the www. address as it’s easy to pick out as a web address. For .com’s this isn’t as important as for .org or .net, IMO, as nowadays most people recognise that “.com” refers to a website.

UnderĀ  Apache this is easy, add this to your .htaccess file in the document root:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Will redirect all addresses that don’t start “” to that same subdomain, so that includes the root domain as well as all subdomains, likeĀ  “”.

Don’t know how this works on IIS, I’m guessing it’s hard and that’s why folks don’t do it.


[Edit: this guy does know how it works on IIS, it is a little more involved, but not much]

2 Responses to "root domain redirection: to"

admin says:

fixed, sorry


Flapjacktastic is just a random collection of musings, hints&tips, notes, information ... a collection of stuff really that's overflowed from the brain of this husband, father, potter, business-man, geek ...

past posts