Blocking an IP Address in Your .htaccess File

If you suspect malicious activity or unauthorized access attempts on your website, you can prevent specific IP addresses from accessing your site by adding the following lines to your .htaccess file:

order allow, deny
deny from IP-ADDRESS
allow from all

Replace IP-ADDRESS with the actual IP address you wish to block. This simple configuration restricts access from the specified IP address while allowing all other traffic to proceed without interruption. Regularly monitoring and updating your .htaccess file can help enhance the security of your website and protect it from potential threats.

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How to protect your .htaccess file?

For security purposes, we recommend you to prevent access to your .htaccess file from...

How to disable directory browsing using .htaccess?

For security purposes, we recommend that you disable directory browsing on your website so no one...

How to restrict directory access by IP address?

To secure your admin area from hackers, we recommend that you allow access only from a selected...

Mastering UFW: A Comprehensive Guide for Debian, Ubuntu, and AlmaLinux

The Uncomplicated Firewall (UFW) offers a user-friendly interface for managing iptables firewall...

Setting Up WireGuard on Debian/Ubuntu for Linux VPS (KVM)

WireGuard is a modern VPN (Virtual Private Network) software that offers state-of-the-art...