Two Domains, One Website

Sometimes it is desirable to have two domain names for the same website. The most common reason for doing this is to accommodate similar alternative spellings.

Let's use the website www.paranormal-encyclopedia.com as an example. The word encyclopedia can also be spelt encyclopaedia. In order to allow for the people who spell it the second way, this website has two URLs:

Now, what to do with the second domain? One solution would be to duplicate the entire website at both domains, but this has many disadvantages and is not recommended. A better alternative is simply to redirect any traffic from the second domain to the main one. Therefore anyone who uses the second URL will be sent straight to the preferred domain without any real delay (they probably won't even notice that it's happened).

Here's how to do it (note: this assumes an Apache server):

If you already have a .htaccess file, open it for editing. If you don't, create a file called .htaccess at the root level of your website. Be careful — you may actually have a hidden .htaccess file so make sure you don't accidentally overwrite it. If you're not sure, ask your web developer or server administrator.

In the .htaccess file, enter the following (substituting the paranormal domains for your own):

RewriteEngine on
RewriteCond %{HTTP_HOST} !^paranormal-encyclopaedia.com/$ [NC]
RewriteRule ^(.*)$ http://www.paranormal-encyclopedia.com/$1 [R]

All traffic for the first domain is redirected to the second domain. Note that we did not include "www" in the first domain — this is to catch all users even if they didn't enter the "www".