Home / Security / How to block an IP address from your website

How to block an IP address from your website

Browser with laptop

It is always important to check your website logs. Many web hosting providers will give you access to them, even if they do not tell you they do. In a virtual hosting account, there will be a log directory with Apache server logs. Among other things, it will tell you the IP addresses of your visitors.

Sometimes you have pesky visitors to your site who just do not get the hint. It may be someone who constantly leaves nasty posts on your message forum or someone with even more malicious intentions. Regardless of the reason, a simple htaccess file can help you tremendously. In the root directory of your website, make an .htaccess file or edit the current one, entering the following information:

order allow,deny
deny from 192.168.0.1
allow from all

You can change the “deny from” to any IP address, and you can add more than one “deny from” line. This will give someone coming from that IP address an access denied error.

Photo Source: Flickr

Check Also

physical servers security

Colocation sever security

Collocation is the movement of the servers from an in house location usually to a …