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

Clearing DNS Cache for Mac or Windows

Your DNS cache stores the locations (IP addresses) of web servers that contain web pages which...

Video: Creating Custom Error Pages in cPanel

This video tutorial provides Step-by-Step instructions for creating custom error pages in

How to backup / restore / cpmove from One cPanel Host to Another?

The best way to transfer cPanel > cPanel is to use the transfer tool: Log into the cPanel...

Video: Login to cPanel

This video provides Step-by-Step Instructions to Login to cPanel Shared Hosting account.

Video: How to Backup Your Website in cPanel

This video tutorial provides Step-by-Step instructions for backing up your website using cPanel...