views:

501

answers:

1

Is this how to use AND, OR for RewriteCond on Apache?

rewritecond A [or]
rewritecond B
rewritecond C [or]
rewritecond D
RewriteRule ... something

becomes if ( (A or B) and (C or D) ) rewrite_it.

So it seems like "OR" is higher precedence than "AND"? Is there a way to easily tell, like in the (A or B) and (C or D) syntax?

+1  A: 

You’ll probably need to convert it into disjunctive normal form:

  (A or B) and (C or D)
= (A and (C or D)) or (B and (C or D))
= (A and C) or (A and D) or (B and C) or (B and D)
Gumbo
How do you use this syntax with RewriteCond?
mattalexx
@mattalexx: Consecutive `RewriteCond` are implicitly combined with AND; an OR combination can be expressed with the *OR* flag. So this can be expressed using eight `RewriteCond`s where each implicitly AND combined pair is OR combined using the *OR* flag.
Gumbo