htaccess的 - 使用密码或IP白名单 [英] htaccess - using password OR ip whitelist
本文介绍了htaccess的 - 使用密码或IP白名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我想限制访问的URL。现在,如果他们是从一个特定的IP地址来了,他们应该不会提示输入密码。如果他们不从得到安宁的IP地址来了,就应该被提示输入密码。
因此任一或:
的AuthUserFile /some/path/.htpasswd
AuthName指令请登录
与AuthType基本
需要有效的用户
和
为了否认,允许
所有否认
允许x.x.x.x
解决方案
您可以使用Apache 满足指令。
下面是使用它的一个例子:
与AuthType基本
AuthName指令请登录
的AuthUserFile /some/path/.htpasswd
需要有效的用户
订单拒绝,允许
所有拒绝
从127.0.0.1允许
满足任何
无密码访问只能从127.0.0.1允许的。
希望这有助于。
So I want to restrict access to a url. Now if they are coming from a given IP address then they shouldn't be prompted for a password. If they are not coming from a givin IP address then they should be prompted for a password.
so a either or of:
AuthUserFile /some/path/.htpasswd
AuthName "Please Log In"
AuthType Basic
require valid-user
and:
order deny,allow
deny from all
allow from x.x.x.x
解决方案
You can use the Apache "Satisfy" directive.
Here is an example of using it :
AuthType Basic
AuthName "Please Log In"
AuthUserFile /some/path/.htpasswd
Require valid-user
Order deny,allow
Deny from all
Allow from 127.0.0.1
Satisfy any
Access without password is only allowed from 127.0.0.1.
Hope this helps.
这篇关于htaccess的 - 使用密码或IP白名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文