Link to home
Start Free TrialLog in
Avatar of movieprodw
movieprodw

asked on

htaccess rewrite all domains to new domain

Hello,

I have 40 domains that point to one domain but they keep their domain names in tact, I want to change that.

Currently I have it so:
domain1.com
domain2.com
domain3.com

show their domain names but actually load
domain.com

I want the htacess to say
if domain.com then nothing, if not domain.com then change the domain name to domain.com and leave the other info in the url

ie
if domain1.com/search/test.php
then rewrite domain.com/search/test.php
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Put this in the VirtualHost for each domain you want to redirect.
RewriteRule  ^/(.*)  http://domain.com/$1  [R,L]

Open in new window

Avatar of movieprodw
movieprodw

ASKER

what if they all use the same htacess, will that create a loop?
No. You will not have this rewrite rule in the VirtualHost for domain.com.
Okay, but I don't have a vitualhost for them, they are just pointed by dns, so there is only one htacess file and one index.php file so I need to make it so if it is domain.com then great, if not then redirect to domain.com/xxxx
ASKER CERTIFIED SOLUTION
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks