Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)

share|improve this question

2 Answers 2

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]
share|improve this answer

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]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.