Welcome to WebmasterWorld Guest from 54.167.174.11

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Need memory verification (mine)

Need to know if I remember a code sequence correctly

   
9:06 pm on Jun 16, 2013 (gmt 0)

10+ Year Member



I need to know if I am remembering a .htaccess directive sequence correctly.

I want to bounce all requests from a particular CIDR in China (Comment spam gang) back to the sending IP. Here is how I think I remember the code:

RewriteCond %{REMOTE_ADDR} ^112\.123\.168\.
RewriteRule (.*) http://%{REMOTE_ADDR} [L]

[edited by: phranque at 12:51 pm (utc) on Jun 17, 2013]
[edit reason] unlinked url [/edit]

9:12 pm on Jun 16, 2013 (gmt 0)

10+ Year Member



Http disappeared and some extra characters appeared before and after the curly brackets, before the [L] command, after I posted this. I don't know why. Here is what I tried to post:

http:// %{REMOTE_ADDR} [L]

Remove the space after http
9:57 pm on Jun 16, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Http disappeared and some extra characters appeared before and after the curly brackets

Uh, yeah, that's why the WebmasterWorld forums insist on "example.com" everywhere. Obviously a bit awkward when the material after http:// is something other than a plain-text domain name, but there you are.

General principle: if you're testing for a literal string, put the same literal string in your target. F'rinstance

RewriteCond %{REMOTE_ADDR} ^112\.123\.168\.(\d+)
RewriteRule .* http:/ /112.123.168.%1 [R=301,L]

No need to capture the request if you're not going to reuse it.

Some people prefer to redirect to 127.0.0.1 and let your offending visitors contemplate their navels. In practice it rarely makes much difference-- unless you're dealing with real humans attached to real browsers.
12:51 pm on Jun 17, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Http disappeared and some extra characters appeared before and after the curly brackets

The
[code]
tags are your friend :)

http://%{REMOTE_ADDR}
3:55 am on Jun 18, 2013 (gmt 0)

10+ Year Member



Thanks Lucy and Readie.