0

I have been scratching my head for almost half an hour already because of this. I don't know what I am doing wrong, might just be under my nose, but i just cant see it. Here's what I have on my .htaccess

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

  RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  RewriteCond %{REQUEST_URI} !^/admin [NC]
  RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]

When I access example.com/admin, i am still redirected to newsite.com/admin.
Can anyone please advise? Thanks!

1

It depends on RewriteBase /. I checked your code with this online tool and it was working fine. Toggling comment for rewritebase line will help but other rules might get affected. Instead, modify your condition and remove the slash. It should work.

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^admin [NC]
RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]
0

Try this:

RedirectMatch 302 /(?!admin)  http://www.newsite.com 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.