Using .htaccess File to Block IPs

You may block access to your website from specific IP addresses using .htaccess file.
You need to create this file in your public_html folder and add these example lines:

order allow,deny
deny from 127.0.0.1
allow from all

These lines will block access for all users using 127.0.0.1 IP address.

If you need to block a group of IP addresses. use these example lines:

order allow,deny
deny from 127.0.0.1/24
allow from all

These lines will block access for all IP addresses within the 127.0.0.1/24 subnet.

Was this answer helpful?

 Print this Article

Also Read

Creating a Spam Email Filter

To create a spam filter, perform the following steps: Navigate to cPanel's  Apache...

Video: How to Enable Spam Protection in cPanel

This video tutorial provides Step-by-Step instructions for enabling spam protection in cPanel...

Video: Modify Account Password in cPanel

This video tutorial provides Step-by-Step instructions for modifying password in cPanel Shared...

How to Backup MySQL Databases

This can be used to back up a database. 1. Export A MySQL Database This example shows you how to...

How to Find the IP of cPanel Server

This tutorial is designed to troubleshoot and diagnose issues with cPanel license errors....