Reputation: 44293
I'm using the following few line in my .htaccess file to redirect from every /something
to /#!/something
url. So I'm redirecting to a hash so I can catch it with javascript. That works perfectly fine …
RewriteEngine on
# not existing file (images, css, etc)
RewriteCond %{REQUEST_FILENAME} !-f
# no query parameters
RewriteCond %{QUERY_STRING} =""
# not /
RewriteCond %{REQUEST_URI} !^/$
# R=redirect, NE=dont escape #, L=last rule
RewriteRule ^(.*)$ /#!/$1 [R,NE,L]
# same but with query parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ /?%{QUERY_STRING}#!/$1 [R,NE,L]
Is there a way to have an exception on that. E.g. when I enter www.test.com/stats
I don't want that to happen!
Upvotes: 0
Views: 1846
Reputation: 143886
Just add this in front of all the rules you want the exception on:
RewriteCond %{REQUEST_URI} !^/stats
And any other URI's you don't want to redirect. You can include them all in the same regex:
RewriteCond %{REQUEST_URI} !^/(stats|something|example|test)
Upvotes: 4