Knowledgebase: General QA
Banning IP Addresses Using .htaccess
Posted by Barry Tarbet on 10 April 2008 06:26 AM

Banning IP Addresses Using .htaccess

There may be times where you want to refuse access to certain robots or visitors to your web site.
You Must use a Html Text Editor, or the Control Panel File Manager / Edit option


> Step One
if using control panel File Manger, - make sure you enable "show hidden files"
locate or create the .htaccess file at the root (yourdomain.com) directory, don't overwrite the existing file if one exists.

1. Basic .htaccess file

order allow,deny
deny from 127.0.0.1
allow from all

This will refuse all GET and POST requests made by IP address 127.0.0.1, an error message is shown instead.

2. More options

To block multiple IP addresses, list them one per line.

order allow,deny
deny from 127.0.0.1
deny from 127.0.0.2
deny from 127.0.0.3
allow from all

You can also block an entire IP block/range. Here we will not specify the last octet in the .htaccess file.

deny from 127.0.0

This will refuse access for any user with an address in the 127.0.0.0 to 127.0.0.255 range.

Instead of using numeric addresses, domain names (and subdomain names) can be used to ban users.

deny from isp_name.com

It bans users with a remote hostname ending in isp_name.com. This would stop all users connected to the internet via isp_name.com from viewing your site.

Using .htaccess to block an entire range or name is likely to lock out innocent users. Use with caution.


thats it !

If you have any problems or questions , please dont hesitate to create a support ticket.

(187 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).