Welcome to WebmasterWorld Guest from 54.159.19.75

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)

Full Member

10+ Year Member

joined:May 5, 2003
posts: 316
votes: 0


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 June 16, 2013 (gmt 0)

Full Member

10+ Year Member

joined:May 5, 2003
posts: 316
votes: 0


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 June 16, 2013 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:12702
votes: 244


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 June 17, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts: 943
votes: 0


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 June 18, 2013 (gmt 0)

Full Member

10+ Year Member

joined:May 5, 2003
posts: 316
votes: 0


Thanks Lucy and Readie.