homepage Welcome to WebmasterWorld Guest from 54.226.147.84
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

    
Redirect Specific Host to Specific Page
redirect ip address range to specific page
hurleygirl



 
Msg#: 4249455 posted 5:53 pm on Jan 5, 2011 (gmt 0)

I'm trying to redirect a specific visitor when they visit my website.

I've been trying a variation of the redirect and can't seem to get it to work. Please tell me what's wrong?

RewriteEngine on
RewriteCond %{REMOTE_HOST} 65\.160
RewriteRule .* /go_away.html [R=301,L]

Your input is greatly appreciated.

 

ncsuEE98



 
Msg#: 4249455 posted 6:47 pm on Jan 5, 2011 (gmt 0)

To prevent an infinite loop, you need to ignore the page where you are redirecting the user (go_away.html). I tested the following on one of our web servers:

RewriteEngine on
RewriteCond %{REMOTE_HOST} 65.160
RewriteCond %{REQUEST_URI} !(go_away.html)
RewriteRule ^(.*)$ /go_away.html [R=301,L]

hurleygirl



 
Msg#: 4249455 posted 7:55 pm on Jan 5, 2011 (gmt 0)

stumped. it's not working on mine.

ncsuEE98



 
Msg#: 4249455 posted 8:12 pm on Jan 5, 2011 (gmt 0)

What entries are you seeing being written to the logs for your request?

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4249455 posted 10:50 pm on Jan 5, 2011 (gmt 0)

Wrong variable being tested and redirect syntax not quite right... Also, optimize-out one rewritecond:

RewriteEngine on
#
# redirect visitors from 65.160.x.y to "go away" page.
RewriteCond %{REMOTE_ADDR} ^65\.160
RewriteRule !^go_away\.html$ http://www.example.com/go_away.html [R=301,L]

Note that this may be taken as goading by some, who may then desire to cause even more trouble for your site. So I'd suggest either making the "go away" page look like a 500_Server Error response, or returning a totally-blank page or a page with a bogus but real-looking error message on it to make it seem that your site is broken. If that's not desirable, then a 403-Forbidden response might be simpler.

RewriteEngine on
#
# respond to visitors from 65.160.x.y with a 403-Forbidden response
RewriteCond %{REMOTE_ADDR} ^65\.160
RewriteRule ^ - [F]

When dealing with troublemakers, it is best not to let it get personal -- either for you or for them. Also, you should *never* give a malicious visitor any information. Information is power, something not to be given to your enemies. Even indicating that "I caught you" is a foolish move, and may only make things worse. So I say 403 them and be done with it... No use worrying about them.

Jim

hurleygirl



 
Msg#: 4249455 posted 1:45 pm on Jan 6, 2011 (gmt 0)

Thank you!

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