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 http://gator123.hostgator.com/~user_name/my_domain.com/
     
  2. or when the site can be accessed by its IP address (example: http://12.34.56.78/)
     
  3. or when you have reserved several domain names for the same web site, typically my_site.com, my_site.net, my_site.de, my_site-and-keywords.com, …
     
  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 gator123.hostgator.com and my_site.net (with and without www) and that the IP address is 12.34.56.78 and that the prefered domain name is www.my_site.com (so with www). A .htaccess file can be used to generate the redirections:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^12.34.56.78$ [OR]
RewriteCond %{HTTP_HOST} ^gator123.hostgator.com$ [OR]
RewriteCond %{HTTP_HOST} ^my_site.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.my_site.net$ [OR]
RewriteCond %{HTTP_HOST} ^my_site.com$
RewriteRule ^(.*) http://www.my_site.com/$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.