Forum Moderators: phranque
# EXCLUDE a few URLs
RewriteCond %{REQUEST_URI}!^/example-page-1\.php$
RewriteCond %{REQUEST_URI}!^/example-page-2\.php$
RewriteCond %{REQUEST_URI}!^/example-page-3\.php$
RewriteCond %{REQUEST_URI}!^/example-page-4\.php$
RewriteCond %{REQUEST_URI}!^/example-page-5\.php$
# Use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ /[^.]+\.php\ HTTP/
RewriteRule etc etc
(The RewriteRule doesn't apply to a few excluded URLs.)
I see that [OR] is sometimes added to the end of RewriteCond (as, for example when banning a list of bots). Under what conditions should [OR] be used? I'd appreciate a pointer.
My example above works ok without.
Patrick
Typically, but not always, [OR] is used with positive-match ^patterns$ while the default AND is used with negative-match !^patterns$ such as yours.
But try actually reading the logic with "If" replacing RewriteCond -- "If request_uri NOT example_page_one AND If request_uri NOT example_page two AND If request_uri NOT example_page three, THEN apply this rule."
Jim
[edited by: jdMorgan at 11:57 pm (utc) on Dec. 7, 2007]
The new code would be:
RewriteCond %{REQUEST_URI} !^/example-page-(1)\.php$
@ g1smd - thanks for the suggestion.
As we're on the subject, please could you explain how things work if there are only some ORs (or is this undefined)? I've never been able to see a clear answer in the docs.
RewriteCond A [OR]
RewriteCond B
RewriteCond C [OR]
RewriteCond D
Is this ((A OR B) AND (C OR D))
or is it (A OR (B AND C) OR D)
Thank you.
Peter.
If you'd like to learn more about the underlying logic of AND and OR and NOT and how they apply to your question, do a search for "DeMorgan's Theorem."
Many thanks for this Jim.
It helped to find a longtime solution in using my desktop tool to search of my extensive local drive data.
Now, if only I could find way to implement your Msg #3523731?
I'd be rocking and rolling ;)
Don