I’m trying to redirect all requests except those beginning with certain paths.
for example,
http://www.example.com/mypath1 shouldn’t redirect
http://www.example.com/mypath2 shouldn’t redirect
Everything else should redirect
So far ive tried getting it working using just one of the exception paths like this:
RewriteRule ^(?!/mypath1/).*$ http://www.google.com/? [R=301,L]
and like this:
RewriteCond %{REQUEST_URI} !^/mypath1/.* [NC]
RewriteRule ^.*$ http://www.google.com/? [R=301,L]`
and like this:
RewriteCond %{REQUEST_FILE} !^/mypath1/.* [NC]
RewriteRule ^.*$ http://www.google.com/? [R=301,L]
However everything I try is just redirecting all requests.
Does anyone know how to do this?
I’ve managed to resolve the issue, the request I was making was getting redirected later in the apache config to an error page which was then being caught by the catch all redirect.
If anyone else is having similar issues I recommend using the apache RewriteLog as this helped pinpoint the issue. To do this just add this in your VHOST: