homepage Welcome to WebmasterWorld Guest from 54.234.60.133
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
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




msg:4584689
 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




msg:4584690
 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




msg:4584704
 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




msg:4584902
 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




msg:4585159
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved