Hochman Consultants - Results Driven Internet Marketing
Client Login

How to Deal with Multiple Domain Names on One Web Site: Redirects

Recommendations:
Apache Logo
With Apache servers
use mod_rewrite

Windows Logo

With Microsoft Windows
Internet Information
Services (IIS) servers
use ISAPI_rewrite

Do you have a portfolio of multiple domain names that all lead to the same web site? Valid reasons for doing this include helping visitors who may type a domain name with spelling mistakes, hyphens, no hyphens or confuse different names, as well as preventing competitors and typosquatters from using a similar domain name. For a few dollars per year per domain name, it often makes sense to buy all the obvious mistakes and permutations of your valuable domains.

When you attach multiple domain names to a site, search engines can become confused and your rankings may suffer. If they find the same page at two or more different URLs, the search engines will sometimes filter out the extra listings, but there's no guarantee of which ones they filter. You also don't want people linking to your site with non-standard domain names because that will tend to divide your inbound link strength.

Why leave it to chance? With a few lines of code you can make sure all your URLs use consistent domain names. When we have multiple domain names on one site, we set up a permanent 301 redirect for any extra domains, as well as the www subdomain or the non-www domain. If you have an Apache web server, add the following code to a .htaccess file in the top level directory, replacing the test domain name with yours:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.test\.com$
RewriteRule ^(.*) http://www.test.com/$1 [L,R=301]

If you are using a Microsoft IIS web server, I recommend using ISAPI_rewrite to simulate Apache's .htaccess feature. To begin, you or your hosting provider needs to install ISAPI_rewrite on the server. Then you would create a httpd.ini file in the top level directory as follows, replacing the test domain name with yours:

RewriteCond Host: (?!^www\.test\.com$).*
RewriteRule (.+) http\://www.test.com$1 [RP,I]

If you have an IIS server, but don't have ISAPI_rewrite, Ian McAnerin has published a very helpful article that explains how the server administrator can set up permanent 301 redirects on IIS .

These solutions assume you prefer to use the www subdomain for your web site. If you would rather have a non-www URL, simply remove each instance of "www\." and "www." from the rewrite conditions and rules. As with all code, please test thoroughly before deploying to your live server.

About the Author

After graduating from Yale with two degrees in Computer Science, Jonathan Hochman set up his own consulting company in 1990. He has been an Internet marketer since 1994. To send feedback, please visit http://www.hochmanconsultants.com/.

Creative Commons License You may distribute this article in its entirety under a Creative Commons Attribution 3.0 License. Please attribute the author by name and link (URL).

For additional information, please contact Hochman Consultants.