Apache - Limitations of logically linking RewriteCond in 2.2/2.4

[亡魂溺海] 提交于 2019-12-08 06:13:20

问题


These days I read a very interesting post about the precedence of [OR] over the implicit [AND]. I really liked the original question as well as highly appreciated answer.

I just recently stumbled upon further problems concerning this topic.

The problems start as soon as you try to express the following:

RewriteCond A
RewriteCond B
RewriteCond C
RewriteRule ...

with A OR (B AND C). Where ever you place the [OR], it won't work:

#resolves to (A OR B) AND C
RewriteCond A [OR]
RewriteCond B
RewriteCond C
RewriteRule ...

#resolves to A AND (B OR C)
RewriteCond A
RewriteCond B [OR]
RewriteCond C
RewriteRule ...

#makes no sense at all with no further cond after c
RewriteCond A
RewriteCond B
RewriteCond C [OR]
RewriteRule ...

It doesn't get better with more RewriteCon, since you'll always need a 'partner' to pair the [OR] with :( My finding was that

You can only express RewriteCond-sets that come from the CNF (conjunctive normal form).

Which, imho, is pretty huge and caused by the lack of an explicit [AND] as well as no possiblity to bracket two Cond together.

PLEEEEASE correct me if I'm wrong, I really hope that I just missed something! Not that you can always code more than one rule to satisfy your needs, but this has really been bugging me, since I had a real user-case where that was needed.


TL;DR

The second you try to express

(block of 'n' ANDs) OR X
# with n > 0
# and X being a random logical expression (or in rewrite-terms: Rewrite-Cond set)

you just can't with current set of logical operators ([OR],!)

来源:https://stackoverflow.com/questions/43261296/apache-limitations-of-logically-linking-rewritecond-in-2-2-2-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!