Luis Valencia
Luis Valencia

Reputation: 33998

How to ignore a URL in a redirect?

I have the following redirect in my store:

Options +FollowSymLinks 
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.mydomain.net$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

However, I want to ignore the redirection for
www.mydomain.net/admin

because its my backend to manage my store and now I cant access my admin because of the URL redirection I set.

Any idea how to do this?

Upvotes: 1

Views: 620

Answers (1)

animuson
animuson

Reputation: 54729

Should be easy enough to just reverse your line to a negation statement so that it applies to everything that does not match the paths you don't want to rewrite:

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

or more preferably just add another rewrite conditional to exclude the admin directory:

RewriteCond %{REQUEST_URI} !^/admin [NC]

They both should work but the second one looks nicer.

Upvotes: 1

Related Questions