301 Redirect for Multiple Domains

If you want to redirect several domains to your main web site, you need to use a 301 redirect placed inside the .htaccess file on your server.

Definition of 301 Redirect

A 301 redirect tells web browsers and search engines that a web page(s) or web site(s) has been permanently moved to a new location. The 301 redirect code includes the web site address to which the resource has been moved. Web browsers will automatically redirect the person to the new location.

When to use 301 Redirect

A 301 redirect should be used to move a web site to a new domain name (URL). Search engines will preserve the search engine rankings the web site had at the previous domain.

Requirements

Apache server (the 301 redirect described will only work on apache servers. Most servers used to host web sites these days run apache.

.htaccess file - this file contains the 301 redirect code and must be placed in the root folder of your server (same location as the inidex.html page)

Same DNS- all domains you wish to redirect should have the same DNS information.

Parked domains - all domains you wish to redirect should be parked on top of your main web site.

301 Redirect Code for redirecting Multiple Domains


Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^www.domain.com[NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

1. First block you need once only.

2. Second block: you need one for each domain.com that needs redirecting.

3. Third block: you need one for each www.domain.com that needs redirecting to www.newdomain.com.

4. Remove all of the blank lines from the above example.

5. Place all code in the .htaccess file in the web root folder.
Check if there is any code in the .htaccess file already as you may overwrite it. If there is, place the 301 redirect code
under this code.

6. Upload file to server - place the .htacess access in the public_html folder or the same folder as your home page.

7. All redirected domains should be parked on top of your main web site. You can usually do this from within the cpanel
that comes with your hosting plan.

8. Prevent duplicate content issues by redirecting all non-www domains to http://www.domain.com/


RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

These domain name variations:

domain.com
http://domain.com
www.domain.com

will now get redirected to http://www.domain.com/

9. Redirect www.domain.com/index.html to http://www.domain.com/
Within your web site navigation structure, you often have pages linking to the home page with the file name: www.domain.com/index.html. This will also cause duplicate content issues. Use the code below to redirect to your main URL…http://www.domain.com/


RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.(html?|php|asp|cfm)\ HTTP/
RewriteRule ^(.*)index\.(html?|php|asp|cfm)$ http://www.domain.com/$1 [R=301,L]

Tips

All spaces in the code are exact and important.
Make sure you copy and paste the code correctly.
Be sure to include a space before each [NC]

The code shown above must go before the other redirects otherwise it will create a redirection chain.

Conclusion

Now your web site can be accessed using multiple domains. The 301 redirect code used above prevents your web site from being accessed by both domain.com and at www.domain.com for each page of the site. If you did not use the 301 redirect code, Google would spider and index them both, treat them as duplicate content and then penalise one version of each page.

By creating the 301 redirect from non-www to www for each domain, only www will be indexed. If you own both a .co.uk and a .com you would redirect everything to www.domain.com if you wanted to be found globally; or if you want to rank well in UK results but are hosted outside the UK, you would redirect everything to www.domain.co.uk.

Resources

301 Redirects for multiple domains

How to Redirect a Web Page Using a 301 Redirect

5 Responses to “301 Redirect for Multiple Domains”

  1. dave cohen Says:

    Great article! I’m working on building a new site for a company - with cart, cc gateway, ssl, etc. However, there is an existing site on another host. In order to reduce problems and downtime, my solution is to set up new domain and get new site ready, then move/park the old domain name with redirect to new domain. The only issue I’m weighing is, do users care/notice that their entered url address was redirected from the site they requested?

  2. Herman Says:

    Hi Dave,

    Users will soon know the new URL after visiting several times. Don’t worry.

  3. David from Florence Says:

    Hi !

    I have three domain names registered with Networksolutions.

    I redirected them to three respective pages in another website I have in another server.

    Is this considered spamming by search engines ?

    Thank you.

    David.

  4. David from Florence Says:

    Ps: to redirect the domain names, I use the option offered by Network solution called “Web forwarding”.

    Is this “clean” ?

  5. casino gaming casino gioca casino game Says:

    vincere alla roulette online…

    Altre play baccarat online roulette system…

Leave a Reply