View Single Post
  #1 (permalink)  
Old 15-08-2007, 12:29 AM
Lawrence Lawrence is offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,226
Thanks: 2
Thanked 82 Times in 82 Posts
Default How to use .htaccess to block IPs and domains from your website.

If you find yourself with a nuisance user or bot that won't go away then this is the way to block them at server level.

If it doesn't already exist, you will need to create a file on your server called .htaccess. If you are using Windows you will need to create a file such as htaccess.txt, upload it to your server then rename it to .htaccess as Windows doesn't like this form of filename.

Place one of the following examples in your .htaccess file with your own choice of IP(s)/domain(s).

This method will block a single IP
Code:
order allow,deny
deny from 65.36.241.81
allow from all
If you find that the abuser uses several IPs within a block then you can deny access to the whole IP block like this

Code:
order allow,deny
deny from 65.36.241
allow from all
You can even use
deny from 65.36
to block a greater range of addresses, though you should be very careful with blocking whole address ranges because you may end up blocking innocent users in the process. Also bear in mind that if it's a user you are trying to block that many people use dynamic IPs.

This is the way to block a domain.

Code:
order allow,deny
deny from internetseer.com
allow from all
Again you have to be careful how you use this due to the risk of blocking innocent users. For example if you used deny from aol.com you would deny access to everyone from AOL!
__________________
Lawrence
Reply With Quote