Hello All,
This post is about blocking an IP using the .htaccess file.
At times we will have to block or whitelist a particular IP access to our domain. In such cases we may have to add the IP in the firewall. The method mentioned here will help us to block an IP without adding it to the firewall.
Wondering what is Htaccess?
Htaccess or Hypertext Access is a configuration file for use on web servers running the Apache Web Server software. The .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer.
How do we block?
1. First of all, open a blank text file and add following htaccess block IP code
<Limit GET POST HEAD> order allow,deny deny from xx.xx.xx.xx allow from all </Limit>
Add the IP instead of “xx.xx.x.xx”
2. Save it with the name “.htaccess”
3. Place it in the home directory of the domain you want to block
NOTE: This method will only block access to your websites, while FTP, Email access will still be available. For blocking them, you will have to make use of CSF or any other similar firewall application.
Hope this tip helps you.