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


MickeyRoush - 1:49 pm on Nov 16, 2012 (gmt 0)


Maybe someone can help clear this up for me. At AskApache he has several RewriteCond directives concatenated, if that's the correct term here.

RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:VIA}%{HTTP:FORWARDED}%{HTTP:USERAGENT_VIA}%{HTTP:X_FORWARDED_FOR}%{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}%{HTTP:HTTP_PC_REMOTE_ADDR}%{HTTP:HTTP_CLIENT_IP} !^$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]


[askapache.com...]

The only part I really want to understand is this part. I'm already familiar with what each condition does/is, my curiosity is the way that they are concatenated.

RewriteCond %{HTTP:VIA}%{HTTP:FORWARDED}%{HTTP:USERAGENT_VIA}%{HTTP:X_FORWARDED_FOR}%{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}%{HTTP:HTTP_PC_REMOTE_ADDR}%{HTTP:HTTP_CLIENT_IP} !^$


What's the pros and cons of doing it this way instead of just separating them on one per line? Or would it achieve the same thing if each one was on it's own line? Like so:

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} !^$


I've been told different things, so I was hopefully someone here could help. Please, I'm not concerned with what the rules actually do, I'm more interested in if there's a benefit by concatenating the conditions or not.


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