How to restrict directory access by IP address?

In order to secure your admin area from abusers it is recommended to restrict access to your admin directory to all IP's except your own. To do this, you need to create a .htaccess file in the directory you want to restrict access to.
For example, if you have a WordPress blog installed and your admin directory is example.com/wp-admin, you should create a .htaccess file in the public_html/wp-admin/ folder and then add this code into the file.

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

(Replace "Your-IP-Address-Here" text with your own IP address, for example 192.168.0.1).
You can test this by accessing your /wp-admin from another IP address which is not allowed by your .htaccess file.

Please note, it is assumed that you know what IP address is and you know that it can be dynamic or static.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to protect a folder with username and password in cPanel?

You can lock a directory with a password by using the cPanel "Password Protected Directories"...

How to ban any IP address via cPanel?

If someone is abusing your website and you want to block abuser's IP address from accessing your...

How to protect your website's images from an external website?

External websites can use <img/> tag to display an image from your website on other...

How to ban any IP address via .htaccess?

If someone is abusing your website and you want to block abuser's IP address from accessing your...

How to disable directory browsing using .htaccess?

For security reasons it is recommended to disable directory browsing of your website so no one...