How to ban a site (or a directory) access by IP address

If you want prevent someone (or something) to access your site from a given IP, you can do it easily adding following lines to your .htaccess file:


order allow,deny
deny from IP-ADDRESS
allow from all


(replace "IP-ADDRESS" with the IP address you need to block)

You can add as many "deny from" commands as needed.

You can specify a single IP (i.e. 111.111.111.111) or a class (i.e. 111.111.111. stay from "all IPs from 111.111.111.1 to 111.111.111.255")



How to restrict a site (or a directory) access by IP address

In order to secure a full site or a single directory (i.e., the admin area of a WordPress site), you can easily allow access only from your own IP.
Edit the .htaccess of the directory to procect, adding following lines:


order deny,allow
deny from all
allow from YOUR-IP-ADDRESS

(replace "YOUR-IP-ADDRESS" with your own IP address)

 

Found this article interesting?
Subscribe to DomainRegister´s newsletter!

You can unsubscribe at any time by simply clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp s privacy practices here.

  • .htaccess, security
  • 24 Users Found This Useful
Was this answer helpful?

Related Articles

 Linux Directory and File Structure

Linux Directory/Folder StructureFrom amongst the several directories found within your cPanel...

 Shared Linux Hosting Plans Technical Specifications

    Cardboard Basic Starter disk space 10 MB 1 GB 2 GB monthly traffic 20...

 Reseller Linux Hosting Plans Technical Specifications

    Starter disk space as provided by plan monthly traffic as provided by plan...

 DNS Configuration for Shared Hosting Plans

In order to use our Linux Shared Hosting Plans, you need point the domain using one of the...

 How to backup your site to a FTP server with cPanel

cPanel offers an easy and powerful way to backup your site, storing your backup set on a remote...