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 Denny, Alllow
    Deny from

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

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Prevent File/Directory Modification, Deletion and Renaming in Linux?

If you are looking to prevent any file from being modified, delete or renaming, you will need to...

How to install CentOS Web Panel on CentOS 7.x

This article will guide you on how to install CentOS Web Panel on CentOS 7.xCentOS web panel is...

How to add IP address in Ubuntu using command?

Sometimes you may require to add the IP Address manually in ubuntu network Interface. Following...

How to enable Analytics Feature from cPanel ?

cPanel has launched the Interface Analytics plugin in WHM version 78. cPanel Analytics plugin...

How to determine what is using the most disk space on a Linux server?

There are times when you receive following error while accessing the cPanel WebMail or WHM. You...