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 192.xxx.xxx.xxx

      Note: replace the IP 192.xxx.xxx.xxx 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 install Virtualmin / Webmin control panel in Ubuntu 18.04?

Please refer to the following steps to install Webmin/Virtualmin on Ubuntu 18.04 Let's run the...

HOW TO INSTALL NEXTCLOUD ON UBUNTU?

Nextcloud is an open-source and secure PHP-based content collaboration platform. It is used for...

How to Disable SELinux on CentOS?

SELinux called Security-Enhanced Linux is a security module of Linux kernel which provides...

How to Increase Open Files Limit in Ubuntu?

You may receive a message on Linux system like "Too many open files". This mean server has...

How to install Google Chrome on Ubuntu 18.04 using the Command Line?

Following are the steps to install Google Chrome using Command-Line. Edit the source.list file...