web analytics

Blog

How to block IP’s using .htaccess

Tags: .htaccessApacheipaddress

Published on: April 21, 2016 by Manu M.

How to block IP’s using .htaccess

Scenario:

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.

Category : Howtos, Linux, Troubleshooting

Manu M.

Manu M.

Manu has been with us for past one and half years and is a person with good technical skills and domain knowledge. Being a highly athletic personality, Manu likes to play Cricket and Badminton of all games whenever he gets time off. Apart from his technical and athletic abilities, he is a good writer and has tried his hands on penning a few poems of his own. He believes in the mantra that "small things matter the most" and this nature can also visible in his blogs and writings.

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Get new updates

Categories

$0.000 items