Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Concatenate Several RewriteCond Directives


lucy24 - 10:50 am on Nov 17, 2012 (gmt 0)


The source rule (referenced from the askapache version) goes:

RewriteCond %{HTTP:VIA} !^$ [OR]
RewriteCond %{HTTP:FORWARDED} !^$ [OR]
RewriteCond %{HTTP:USERAGENT_VIA} !^$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} !^$ [OR]
RewriteCond %{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
RewriteCond %{HTTP:HTTP_CLIENT_IP} !^$
RewriteRule ^(.*)$ - [F]


So it's no longer "If any of group A [OR] any of group B is non-empty"; it's "If any one of these eight items are non-empty". The result is exactly the same because what you're saying is a+b+c+d+e != "". Since you can't have a negative string, it's the same thing as
a != ""
OR
b != ""
OR
c != ""
et cetera.

Yes, I realize that in my previous post I misread the punctuation, making it "all A OR all B are empty" rather than "any of A or any of B are non-empty". Slight, ahem, difference.

Concatenation works in this specific case because everything on the list has to be empty. 0 + 0 + 0 + ... + 0 + 0 = 0, vs. 0 + 0 + 0 + ... + 0 + 0 + non-zero = non-zero.

Incidentally: everyone got so wrapped up in the conditions that we never made it to the Rule itself. I think it's funny that the original
^(.*)$ - [F]
was changed to
.* - [F,NS,L]
getting rid of one minor error --an unneeded capture with anchors- and replacing it with a different one --a slightly iffy set of flags. L with F is definitely redundant; NS is sometimes appropriate but shouldn't be thrown around like confetti. Could a subrequest ever come in through a proxy? Not necessarily a law-abiding subrequest: Is it physically possible?


Thread source:: http://www.webmasterworld.com/apache/4519705.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com