Forum Moderators: phranque

Message Too Old, No Replies

Blocking Range

         

keyplyr

6:10 am on Jan 21, 2004 (gmt 0)

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



How would condense this range?

122.122.0.0 - 122.122.255.255

Thanks

jdMorgan

6:43 am on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi keyplyr,

Just leave the last two octets off completely, and don't use an end-anchor: ^122\.122\. will match anything that starts with "122.122."

Jim

keyplyr

7:50 am on Jan 21, 2004 (gmt 0)

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



- related -

...which brings up the issue about ending anchors. This other IP range...

RewriteCond %{REMOTE_ADDR} ^123\.123\.144\.1[1-3]$

Should have that ending anchor huh?
(I didn't have it there)

Thanks

<added>

I've decide on blocking the entire range that includes the above IPs.

123.123.128.0 - 123.123.159.255

So it would be like this?

123\.123\.1[28-59]\.

jdMorgan

6:04 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Include an end anchor only if you specify all digits. Leave it off if your pattern ends with "\."

Your code to block the range looks OK.

Jim

tito

7:17 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



please, is the following code correct to block a specific IP (single IP, not a range)?!?
RewriteCond %{REMOTE_ADDR} ^218.****.**.**$ [OR]

also please, what about the following:
RewriteCond %{REMOTE_ADDR} "^63\.148\.99\.2(2[4-9]¦[3-4][0-9]¦5[0-5])$" [OR]
do i have to include IP between " as above mentioned or not?

thanks for help

jdMorgan

7:40 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tito,

You need to escape the dots between numbers by preceding them with "\" OR enclose the whole pattern within quotes.

Jim

tito

9:19 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



Thanks jdMorgan, pls confirm me if i get to the point, i will write to block a single IP :
RewriteCond %{REMOTE_ADDR} ^218.****.**.**$ [OR]

and to block a range, like this:
RewriteCond %{REMOTE_ADDR} ^63\.148\.99\.2(2[4-9]¦[3-4][0-9]¦5[0-5])$ [OR]

sorry to bother you but i'm just a beginner, i'm actually digging into rewriting rules, hopefully i'll do better in a few days,
thanks again
tito

hakre

9:47 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi tito for some more infos about regular expressions, you can checkout these threads:

regular expression basics [webmasterworld.com]
Regular expressions - A bit of a reference [webmasterworld.com]

to know the regular expressions helps a lot for writing rewrites.
-hakre

tito

10:44 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



Thanks for the food for thoughts Hakre, that's exactly what i need.

cheers
tito