How to restrict access using .htaccess

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)

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What do I need to do to put Flash on my website?

Flash is a client side feature - it runs on the user's computer, not on your web host. As long as...

What are private nameservers and how do I set them up?

Private nameservers are where your domain points to our nameservers so that your customers do not...

Static IP vs. Dynamic IP Address

A static IP address is one that remains fixed and never changes. The PC always sees the same...

Protecting Yourself Against Viruses & Data Loss

It is vital to ensure your computer is protected from viruses and trojans. As well as...

How to Upgrade perl?

Run the following command. cd /usr/local/src ; wget...