The search engine friendly way to merge domains

This content is 18 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

In common with many website owners, I have multiple domain names pointing at a single website (markwilson.co.uk, markwilson.me.uk and markwilson.it). There’s nothing wrong with that (it’s often used to present localised content or to protect a trademark) but certain search engines will penalise sites where it appears that multiple URLs are being used to present duplicate content (hence increasing the link count and inflating the position within the index).

The trick is to ensure that the domains are merged in a manner which is acceptable to the major search engines. It’s generally accepted that the way to do this is to choose the primary domain name (in my case, that’s markwilson.co.uk) and to rewrite any requests received by the web server(s) on any secondary domain names so that they are redirected to the primary domain name (using HTTP status code 301 – moved permanently).

For a site running on an Apache web server with the mod_rewrite module compiled, this is achieved using some directives in the .htaccess file. A description of the required code can be found in various locations, including Brian V Bonini’s 301 permanent redirect article but my site uses some code from a recent .net magazine article to combine the domain name rewrite with the placement of any missing www prefix:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^primarydomain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?secondarydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.primarydomain.com/$1 [R=301,L]

After making the changes, it’s important to check the server headers (e.g. using the SEO Consultants check server headers tool) and ensure that the server is correctly returning an HTTP status code 301 that redirects to the primary domain name, hopefully resulting in an eventual HTTP status code 200 – OK:

#1 Server Response: http://www.secondarydomain.com/
HTTP Status Code: HTTP/1.1 301 Moved Permanently
Date: Tue, 27 Feb 2007 15:19:42 GMT
Server: serverdetails
Location: http://www.primarydomain.com/
Connection: close
Content-Type: text/html; charset=iso-8859-1
Redirect Target: http://www.primarydomain.com/

#2 Server Response: http://www.primarydomain.com/
HTTP Status Code: HTTP/1.1 200 OK
Date: Tue, 27 Feb 2007 15:19:44 GMT
Server: serverdetails
Connection: close
Content-Type: text/html

6 thoughts on “The search engine friendly way to merge domains

  1. Mark,

    I scoured the web for hours trying to figure out how to take two domains, same ip and have them redirect properly. There were so many ways and code available but few worked like yours. Thanks again or thanks for copying it from a great place;)

  2. Thanks so much Mark,

    I have just discovered rewrite today, and realised I could achieve what I wanted to – ie forcing http://g2n.org.uk and http://gifttonature.co.uk to point to http://www.gifttonature.org.uk. Your post has shown me just how, and it works a treat, thanks. It has also helped me understand the process a bit more, which has assisted with setting up a link indexing script on another site (which is what originally set me off looking at rewrite). That now works nicely in theory, just need to tidy it up!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.