1

Ok guys I need to add an exception! How can I do this? I currently use RewriteRule ([^.]+).html $1 [R=301,L] to rewrite all .html urls

I do need the exception for the google.html verification file. How can I set this exception?

I tried this but it doesnt work. Any ideas?
RewriteCond $1 !^(google022e525bdb654772.html|googleb5e92d18c6640aeb.html)/?

and I tried

RewriteCond $1 !^(google022e525bdb654772.html|googleb5e92d18c6640aeb.html)

2 Answers 2

3

What you have isn't working because backreferences (like $1) in a RewriteCond refer to groups in the last matched RewriteCond rather than the RewriteRule.

Try the following instead:

RewriteCond %{REQUEST_URI} !^/google(022e525bdb654772|b5e92d18c6640aeb)\.html
RewriteRule ([^.]+).html $1 [R=301,L]
0

Rewrites are processed in order. Put in a rewrite which makes no changes, but declares itself the last rewrite, before your normal rewrites.

It's generally bad to litter rewrites with information of what they're not about, which has to be read past, when you can get the exceptions dealt with and out of the way instead.

RewriteRule ^/google022e525bdb654772.html$  -  [L]
RewriteRule ^/googleb5e92d18c6640aeb.html$  -  [L]
RewriteRule ([^.]+).html $1 [R=301,L]

You must log in to answer this question.