Forum Moderators: phranque
RewriteCond %{REMOTE_ADDR} ^x\.x\.([0-9]¦[1-3][01])\. [OR]
This blocks 0-9, 10, 11, 20, 21, 30, & 31 only.
Always remember that RewriteCond is doing a text character compare, and not a true nummeric range evaluation.
A more-correct regex for .0. - .31. would be \.([12]?[0-9]¦3[01])\.
Jim
I'm a bit confused now :/ A while ago you've written the following:
**********************************************
In order to match a numeric range of 0-112, you have to cover all possible character combinations:
[0-9] for 0-9
[1-9][0-9] for 10-99
10[0-9] for 100-109
11[012] for 110-112
So the whole mess, when put together, looks like this:
^***\.***\.([0-9]¦[1-9][0-9]¦10[0-9]¦11[012])\.
You can shorten that slightly, to:
^***\.***\.([1-9]?[0-9]¦10[0-9]¦11[012])\.
**********************************************
In the above example, you used [1-9][0-9] for the range 10-99. In my case, I used [1-3][01] for the range 10-31. Isn't that the same logic?
So [12]?[0-9] means 0 through 9, 10 through 19, or 20 through 29.
You could write that more clearly but less efficiently as [0-9]¦[1-2][0-9]
For more information, see the regular-expressions turtorial cited in our forum charter [webmasterworld.com]. There are also many "better" regex tutorials on the Web, but this one is short and to the point.
Jim