Multiple Domain Names to One Site

Sometimes a website can be reached through multiple domain names.

This happens more often than you think :

  1. when the site can be called by a “technical address” from the hosting company, like
  2. or when the site can be accessed by its IP address (example:
  3. or when you have reserved several domain names for the same web site, typically,,,, …
  4. or when you decide to replace an old domain name by a new one

For the sake of clarity for the users and from a search engine optimization prospective (duplicate content issues), one should always choose his/her prefered domain. The prefered (or canonical) domain name should be used in all public communications about the website. One should try to convince others to use the prefered domain in all inbound links pointing to the site. This will concentrate all the “link juice” to the prefered address rather than spreading it among different domain names.

For the best canonicalization (i.e. to avoid duplicate content issues), all secondary domains should be redirected (301 redirection) to the prefered domain.

Say that the secondary domains are and (with and without www) and that the IP address is and that the prefered domain name is (so with www). A .htaccess file can be used to generate the redirections:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$1 [QSA,L,R=301]

The syntax above is obvious. Note that there is no [OR] at the end of the last condition and that only the host name (domain name or IP address) must be used. Do not add any directory or file name.

With this .htaccess file, search engine crawlers and visitors who try to access the site through a secondary address will be automaticaly redirected to the prefered domain.