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
PHPApache Web Server

Avatar of undefined
Last Comment
movieprodw

8/22/2022 - Mon
Mark Bullock

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

Open in new window

movieprodw

ASKER
what if they all use the same htacess, will that create a loop?
Mark Bullock

No. You will not have this rewrite rule in the VirtualHost for domain.com.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
movieprodw

ASKER
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
Mark Bullock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
movieprodw

ASKER
Thanks