Forum Moderators: phranque

Message Too Old, No Replies

rewriterule binary operators

         

motorhaven

5:06 am on May 5, 2012 (gmt 0)

10+ Year Member Top Contributors Of The Month



Reading through the Apache documentation here:
[httpd.apache.org...]

I find two interesting binary operators:

-ipmatch
IP address matches address/netmask

-R
Same as "%{REMOTE_ADDR} -ipmatch ...", but more efficient

Has any used any of these with rewriterules to match IPs against a netmask? It has to be far more efficient that all the various string matches, plus you don't have to convert netmasks.

lucy24

9:52 am on May 5, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Excuse me while I run around the room screaming with excitement. Where do you find this stuff?! Is it new to 2.4 or was it hiding all along?

wilderness

12:52 pm on May 5, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's a previous thread (maybe 3-4 years) on something similar in the SSID forum.

However as I recall it. the process was related to conversion, then adding the converted binaries to tables for request lookups.

In the end the latter was determined to be a re-invention of the existing wheel.

motorhaven

4:29 pm on May 6, 2012 (gmt 0)

10+ Year Member Top Contributors Of The Month



It appears new in 2.4. I'm still using 2.2, hence the reason I asked if anyone has tried it. If it works as advertised this feature alone would be worth upgrading to to 2.4.

lucy24

9:04 pm on May 6, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No kidding. That's assuming I've understood it right: instead of saying

%{REMOTE_ADDR} ^123\.(4[8-9]|5[0-9]|6[0-3])\.

you'd be able to make RewriteRules with

{blahblah} 123.48.0.0/12 {blahblah}

using the same blocks you've already got fully internalized? *


* For a given definition of "you", anyway. If a block starts at 64, the one before it might be 62-63, 60-63, 55-63, 48-63, 32-63, 0-63.** I'm surprised at how fast it became automatic.

** Unless it's based in Vietnam, where it is always 48-63 even if it means a ###load of /20 blocks adding up to a single /13. I am not making this up.