Avatar of movieprodw
movieprodw
 asked on

htaccess check domain then redirect if

Hello,

I have domains

1.com
2.com
3.com
4.com
home.com

They are all running off the same web server pointed to home.com

Their domain stays 1/2/3/4

Their is a directory called /account

If #.com/account then redirect to home.com/account

If home.com/account then do nothing
Apache Web ServerPHP

Avatar of undefined
Last Comment
Dan Craciun

8/22/2022 - Mon
Dan Craciun

Try this:
rewriterule ^account(.*)$ http://home.com/account$1 [r=301,nc]

Open in new window

HTH,
Dan
movieprodw

ASKER
This is what I get:

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    This problem can sometimes be caused by disabling or refusing to accept cookies.

Open in new window


Note: they both have the same htaccess
Dan Craciun

I think that's because I created a circular reference, so the server will keep trying to get to http://home.com/account.

Let me find out how I can prevent the server from redirecting if it's already on that page.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
Dan Craciun

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
Perfect
Dan Craciun

Glad I could help!