Portal Home > Knowledgebase > General Support > Blocking IPs with .htaccess


Blocking IPs with .htaccess



There may be times where you want to refuse access to certain robots or human visitors to your website.

The easiest way to block a single IP is through the "IP Deny Manager" in cPanel, however if you need to block a large number of addresses you can also do the following in your .htaccess file:

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 the IP address 127.0.0.1.

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 and 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 numberic addresses, domain names and subdomain names can also be used.

deny from isp_name.com


This 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.


Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
How to install SIM (Views: 1381)
Performing a Tracert (Views: 1629)