homepage Welcome to WebmasterWorld Guest from 54.196.63.93
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Need memory verification (mine)
Need to know if I remember a code sequence correctly
Wizcrafts

10+ Year Member



 
Msg#: 4584687 posted 9:06 pm on Jun 16, 2013 (gmt 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]

 

Wizcrafts

10+ Year Member



 
Msg#: 4584687 posted 9:12 pm on Jun 16, 2013 (gmt 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

lucy24

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



 
Msg#: 4584687 posted 9:57 pm on Jun 16, 2013 (gmt 0)

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.

Readie

WebmasterWorld Senior Member



 
Msg#: 4584687 posted 12:51 pm on Jun 17, 2013 (gmt 0)

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

The
[code] tags are your friend :)

http://%{REMOTE_ADDR}
Wizcrafts

10+ Year Member



 
Msg#: 4584687 posted 3:55 am on Jun 18, 2013 (gmt 0)

Thanks Lucy and Readie.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved