Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect multiple domains to one domain (with or without www before)

I have about 18 domains that need to be redirected to a new one. It has to work both with or without www prepended.

I've tried this:

<IfModule mod_rewrite.c>
    RewriteEngine on 
    Rewritecond %{HTTP_HOST} !^www\.domain\.com
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>

That gives me a redirect loop (and only works with www before, i think?).

like image 400
qwerty Avatar asked Jun 28 '13 13:06

qwerty


People also ask

Is multiple domains pointing to single website good for SEO?

I can tell you now, having one “website” answer to multiple domains simply creates multiple websites of duplicate content and that is absolutely not beneficial for SEO and/or Google.

How do I forward multiple domains to one website?

Pointing two URLs to the same website is a good way to direct traffic to your site from several different domain names. You can accomplish this in two ways: either redirect one of the URLs to your primary domain, or create an alias for one of the URLs. The alias would point that domain towards your primary domain.

Can I connect 2 domains for one website?

With most registrars, it's easy to forward multiple domains to your website so you can simply create one site and then redirect visitors who type one of your other domain names to that one website.

Can multiple domain names point to the same site?

It is possible to have multiple domains point to the same site or a directory on your site. To do this, simply assign both Addon Domains to the same directory (folder). Pro Tip: Secure more than one variation of your domain to protect your brand. Register a new domain now.


1 Answers

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain1.com [OR]
RewriteCond %{HTTP_HOST} ^domain2.com [OR]
RewriteCond %{HTTP_HOST} ^domain3.com [OR]
RewriteCond %{HTTP_HOST} ^domain4.com [OR]
RewriteCond %{HTTP_HOST} ^domain5.com
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=permanent,L]

This will redirect all your 18 domains to your new single domain www.newdomain.com.


Otherwise you can use following code to redirect each domain if they are on separate hosting:

RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=permanent,L]
like image 50
Muddassar Ahmad Avatar answered Sep 23 '22 18:09

Muddassar Ahmad