Forum Moderators: phranque

Message Too Old, No Replies

Rewrite Regex syntax -- Am I right?

         

guillermo5000

12:06 am on Jun 2, 2004 (gmt 0)

10+ Year Member



I have a rewrite that doesn't seem to work. Can anyone check my work. Thank you!

RewriteCond %{REMOTE_ADDR} ^00\.000\.6\.81$ [OR]
RewriteCond %{REMOTE_ADDR} ^00\.000\.6\.(7[4-5]¦8)$
RewriteRule .* - [F,L]

I'm attempting to catch
00.000.6.81
00.000.6.74
00.000.6.75
00.000.6.78

guillermo5000

12:16 am on Jun 2, 2004 (gmt 0)

10+ Year Member



Perhaps the last rewrite should read

RewriteCond %{REMOTE_ADDR} ^00\.000\.6\.(7[4-5]¦78)$

?

Thanks all!

jdMorgan

2:04 am on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest:

RewriteCond %{REMOTE_ADDR} ^00\.000\.6\.(7[458]¦81)$
RewriteRule .* - [F]

Replace the broken vertical pipe "¦" character with a solid pipe before use.

Jim

guillermo5000

2:21 am on Jun 2, 2004 (gmt 0)

10+ Year Member



Ahh! Much simpler. Thank you!

guillermo5000

2:23 am on Jun 2, 2004 (gmt 0)

10+ Year Member



For the sake of learning, does mine work?

jdMorgan

2:35 am on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it should work fine for the .74, .75, and .78 IP addresses. You have used a range "7[4-5]" and then a separate "78". When the range is only a difference of one (5-4=1), then the simpler "one of alternates" [45] method is faster, plus you can then add in the "8" making it 7[458], and then 'or' in the "81" as shown so that a second RewriteCond is not needed. "[4-58]" would also work, but again, since the range is only a difference of one, "[458]" is faster to process.

Jim

guillermo5000

3:01 am on Jun 2, 2004 (gmt 0)

10+ Year Member



Thank you for the great info!