Posted on
June 14th, 2008 by graeinler
Filed under:
Microsoft,
tips - howto's,
webhosting,
websites |
No Comments »
I use Windows for everyday computing generally because this is what I’ve been used. This doesn’t equate to me not being linux fanboy though. This said, I’m not, or will ever use or even suggest a Windows Server for a number of good reasons. This including the simple method of blocking an IP address to access your server. On linux, you can setup a script to dynamically add in the ip addresses to your .htaccess file. On windows this is quite cumbersome. The first method I have provided relies on SSI and Javascript to block the intruder (and in most cases those spam bots are not even using a browser). Nevertheless, if your on Windows the following scripts I have provided below should help you.
<script type=”text/javascript”>
‘var handleips=bannedips.join(”|”) handleips=new RegExp(handleips, “i”)
if (ip.search(handleips)!=-1){ alert(”Your IP has been banned from this site. Redirecting…”) window.location.replace(”http://www.google.com”) } // –>
This script relies on SSI (.shtml extension) in order to work. The ip addresses listed would then be redirected to the site you have provided. Note though that if the intruder disables JavaScript in the browser, the script will become futile.
Here is another asp script that you can use to block certain ip as well and the one which I prefer and would strongly suggest.
<%
EnableSessionState=False
ip = Request.ServerVariables(”REMOTE_HOST”)
if ip = “12.123.1234.123″ or host = “23.23.23.23″ then
response.redirect(”http://database-support.co.uk/access_deny.htm”)
else
response.redirect(”http://domain.com/test.html”)
end if
%>
Do you know of any other method? Please let me know.
Have fun.