How To 301 Redirect Multiple Domains Into One Domain

How To 301 Redirect Multiple Domains Into One Domain

The Problem

If you need to do a 301 redirect between multiple domain names, and force all domains to direct to the "www", use the following code in your .htaccess file.

RewriteCond %{HTTP_Host} ^(www\.)?secondary-domain1\.com$ [NC]
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [L,R=301]

RewriteCond %{HTTP_Host} ^(www\.)?secondary-domain2\.com$ [NC]
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [L,R=301]

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

And that's how you would do a 301 redirect between multiple domain names, and force the "www" version of your main domain.  The code above is for a .htaccess file on an apache server.

The Solution

Related Posts

Redirect all requests to a canonical domain

Dustin Currie
Read more

Drupal for Domain Investors

Lee Raney
Read more

Drupal URL Redirect after Node Creation

Chris Sloan
Read more

Don't sync Drupal files to local environments. Redirect them Instead.

Mark Carver
Read more

3 Ways to Optimize Your Website to Rank for Multiple Locations

Felipa Villegas
Read more

Create Many Social Media Profiles Using Only One Email Address

Ahmad Kharbat
Read more