0

I'm trying to figure out how to redirect one URL to one location:

http://mydomain.com/admin to http://mydomain.com/admin 

And have all other requests from

http://mydomain.com point to http://myotherdomain.com 

So essentially all other requests will redirect to myotherdomain.com except for http://mydomain.com/admin

I've tried setting up a Redirect rule in Apache but I'm not having any luck. I get a "The page isn't redirecting properly" message.

<VirtualHost *:80> ServerName mydomain.com ServerAlias www.mydomain.com DocumentRoot /opt/www/mydomain.com/ Redirect /admin http://mydomain.com/admin Redirect / http://www.myotherdomain.com </VirtualHost> 

1 Answer 1

2

Did you try (note the trailing slash):

Redirect /admin http://mydomain.com/admin/ 

Otherwise it would match /admin again in the Redirect, and get stuck in the loop you mentioned.

Alternatively, you could use mod_rewrite (untested):

RewriteEngine On RewriteCond %{REQUEST_URI} !admin RewriteRule (.*) http://myotherdomain.com$1 [L] 

(Apache will automatically redirect http://mydomain.com/dir to http://mydomain.com/dir/ for any directory, so you would just need to refine the RewriteCond.)

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.