Restrict access via htaccess via ipaddress

From Brian Nelson Ramblings
Jump to: navigation, search

Restrict access via htaccess via ipaddress

This can be a very effective way to protect your Wordpress administrator directory. Any other directory in public_html can be protected in the same way. This method only works if you have a static IP address assigned to you. Anyone attempting to browse such directories using a different IP Address will get a 403 Forbidden error.

Lets restrict access to the wp-admin/ folder in wordpress

vim /path/to/wordpress/wp-admin/.htaccess

Now lets restrict all access but one ipaddress

Order Deny,Allow
Deny from all
Allow from

In the example above the is my public ipaddress.

You can get your public facing ipaddress by visiting

  • Optional: You can enter partial IP Addresses, such as, 100.100.100. This allows access to a range of addresses.