View Full Version : [ubuntu] htaccess allowing one ip with authentication?

August 6th, 2012, 12:40 AM

i want to set up .htaccess on my Apache web server such that all users are straight-up denied access except one user which is my IP. Since this IP represents my entire home network, I also want to add authentication in the case the IP is correct to ensure that only I can access that directory and no one else using my home network.

This is how my .htaccess file looks so far:

Order deny,allow
Deny from all
AuthType Basic
AuthUserFile /var/www/path_to_forbiden_dir/.htpasswd
AuthName "Protected"
require valid-user
Allow from xxx.xx.xx.xxx

where xxx.xx.xx.xxx is my IP

This works in denying IPs outside the local network, however no authentication is shown when I try to access that directory from the IP specified. So, how can I create authentication only for the IP specified?

August 6th, 2012, 01:36 AM
I resolved the issue after re-reading https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles