Iman
Iman

Reputation: 533

How to combine multiple domains?

Assume that I have 3 domains for a website. one of the is the main domain. eg:

1) abc.com (main domain)

2) myabc.com

3) abcmy.com

If want to arrange domains 2 and 3 such that when a user enters enters myabc.com or abcmy.com, he/she redirects to abc.com (the URL in browser must change to abc.com)

Can I use in by editing htaccess file? (Plz assume that I cant use Addon Domains)

Programming language: PHP

Upvotes: 1

Views: 239

Answers (1)

Jasper
Jasper

Reputation: 11908

Yes, you can do this in your .htaccess using mod_rewrite.

This should do the trick:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.myabc.com$ [OR]
RewriteCond %{HTTP_HOST} ^myabc.com$     [OR]
RewriteCond %{HTTP_HOST} ^www.abcmy.com$ [OR]
RewriteCond %{HTTP_HOST} ^abcmy.com$

RewriteRule ^(.*)$ http://www.abc.com/$1 [L,R=301]

Upvotes: 2

Related Questions