How to block an IP address using .htaccess?

You can block traffic coming from any specific IP addresses with .htaaccess file. Please refer to the below steps to block ip address using .htaccess.

  1. Login to your cPanel account and open the file manager.

    file manager

  2. Open the pubic_html directory.

  3. Click on the setting and tick the Show Hidden Files (dotfiles) option and click save.

    show hidden files

  4. Right-click on the .htaccess file and click on the edit.

  5. Insert the following lines inside .htaccess file as shown in the screen capture and save the file.

    Order Deny, Allow
    Deny from

      Note: replace the IP with the actual IP address, you want to block for your website.

Related Articles

How you can change the ip address of the domain in Webmin control panel?

Following are the steps to change the IP Address of the domain in Webmin control panel. Login...

How to Enable Extended Logging in Exim?

Extended Exim log is helpful in troubleshooting Exim issues on Linux Server. It allows you to add...

How to Install Tomcat 7 on Centos?

Tomcat is an open-source web server that is built in Java Servlet and JavaServer Pages...

How can I view my website before DNS changes?

Before DNS propagation takes place, you can browse your website wite temporary URL. Following are...

How to fix su USER Fails With "su: cannot create child process: Resource temporarily unavailable" Error in CloudLinux?

You may face the below error while switching the accounts using su command. su accutest su:...

  • 0 Users Found This Useful

Was this answer helpful?