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

How to Generate/Download a Full Backup in cPanel

A full backup is a backup of all of your entire cPanel Shared Hosting account (files, email,...

How to Edit Zone File and Setup DNS Forwarding

To perform DNS forwarding, change your zone file, (MX, A-Records & CNAME) using the...

How to Install Softaculous with cPanel/WHM

This guide will show you how to download and install Softaculous on your cPanel/WHM server. To...

Video: Update Contact Information in cPanel

This video tutorial provides Step-by-Step instructions for updating contact information in cPanel...

Video: Creating Custom Error Pages in cPanel

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