Click to See Complete Forum and Search --> : Blocking IPs and redirecting them to another page
Seanver
04-29-2006, 12:13 PM
Hi, I know how to prevent IPs from accessing a directory on my website using .htaccess.
But not only would I like to block those IPs, but also to redirect them automatically to a certain .html page.
Any ideas? Given that by blocking access to a directory no page on that directory may be shown to the blocked IPs, it is not a problem if the .html file to which I want to redirect them should be on another directory.
All I want is to block those IPs and, at the same time, while not allowing them to access any file on that directory, redirect them to another page.
Thanks in advance :)
Kevey
04-29-2006, 12:17 PM
This is one way:
<%
Dim sBlockedIP
sBlockedIP = Request.ServerVariables("REMOTE_ADDR")
'Is this IP one that is blocked
If sBlockedIP = "32.454.42.12" Then
'banned IP then redirected to another_page.asp
Response.Redirect "another_page.asp"
End If
%>
Kevey
04-29-2006, 12:29 PM
Using just .htaccess you could try this:
<Limit GET>
order allow,deny
allow from all
deny from 123.456.789.0
deny from 123.4.5.23
ErrorDocument 403 /403.htm
</Limit>
Then, instead of directing them to an error page, just direct them to whatever page you had in mind.
Seanver
04-29-2006, 12:54 PM
Thank you very much! Looks like it works
Kevey
04-29-2006, 02:48 PM
no problem...glad to help.
pcthug
04-29-2006, 05:17 PM
The only problem is that some ISP's allocate and change IP's frequently between users, which can result in blocking out valid viewers of your site and occasionaly letting the culprit back in.
Kevey
04-29-2006, 05:31 PM
If you are dial-up then this is especially true as they use DHCP vice static IPs. I've tried to block a certain bot in the past, but they hit me with several different class C's containing hundreds of IPs each. I would have to block half the Internet to stop them.
felgall
04-30-2006, 04:02 PM
A lot of broadband providers also change their customers IP addresses at regular intervals and even where a static address is provided there is often an option to be able to change it for a different one when required.
brasspenguins
05-01-2006, 11:10 AM
Using just .htaccess you could try this:
<Limit GET>
order allow,deny
allow from all
deny from 123.456.789.0
deny from 123.4.5.23
ErrorDocument 403 /403.htm
</Limit>
Then, instead of directing them to an error page, just direct them to whatever page you had in mind.
WAIT!! What's this .htaccess? How does it work? This looks very useful.
Kevey
05-01-2006, 04:27 PM
It has a bunch of uses...here' a guide for you to check out:
http://www.javascriptkit.com/howto/htaccess.shtml