设置htaccess以便除了一个IP之外每个人都被拒绝,但它需要认证(Set up htaccess so that everyone is denied except one IP, BUT it requires authenticaion)

我想在我的Apache Web服务器上设置.htaccess,以便所有用户都被直接拒绝访问,除了一个用户是我的IP。 由于此IP代表我的整个家庭网络,我还想在IP正确的情况下添加身份验证,以确保只有我可以访问该目录而没有其他人使用我的家庭网络。

这是我的.htaccess文件到目前为止的样子:

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

其中xxx.xx.xx.xxx是我的IP

这适用于拒绝本地网络外部的IP,但是当我尝试从指定的IP访问该目录时,不会显示任何身份验证。 那么,我怎样才能为指定的IP创建身份验证?

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?

最满意答案

尝试在您的.htaccess添加Satisfy all

Thanks, but I resolved the issue by following the instructions on https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles I had forgotten to set up Directory override of htpasswd in apache2.conf

更多推荐