Forum Moderators: phranque
RewriteCond %{REMOTE_ADDR} ^000\.000\.([6-9]¦[4-9][0-9]¦10[0-9]¦1[12][0-7])\.$
I've thought the condition is written correctly, since today when I've seen in my logs that 000.000.88.162 was successfully accessing my website. Can someone explain why my condition isn't good and how it should be written?
Thanks.
RewriteCond %{REMOTE_ADDR} ^000\.000\.([6-9]¦[4-9][0-9]¦10[0-9]¦1[12][0-7])\.$
RewriteCond uses a string compare. That is, it compares characters, not numerical values. So it is necessary to break the problem into several pieces:
First, since the last octet is 0-255 --the entire valid range of an octet-- we can ignore it completely. I won't show the first two digits here either, because they don't change.
Range ........... Pattern
64.0. -- 69.255. 6[4-9]\.
70.0. -- 99.255. [7-9][0-9]\.
100.0. - 119.255. 1[01][0-9]\.
120.0. - 127.255. 12[0-7]\.
( 6[4-9] ¦ [7-9][0-9] ¦ 1[01][0-9] ¦ 12[0-7] ) \.
Finally, add the RewriteCond, a start anchor, and the fixed parts of the pattern, and remove the extra whitespace:
RewriteCond %{REMOTE_ADDR} ^000\.000\.(6[4-9]¦[7-9][0-9]¦1[01][0-9]¦12[0-7])\.
Replace the broken pipe "¦" characters above with solid pipes before trying to use this code; Posting on this forum modifies the pipe character, and will cause a server error if not corrected.
Jim