除了Apacheconfiguration中指定的用户代理以外,是否可以要求基本authentication?
PS我知道,用户代理可以很容易伪造,但对于我的用例这种条件authentication就足够了。
经过不less尝试,我找出了答案。 在他们的.htaccess文件中需要这些行:
SetEnvIf User-Agent ^VipAgent1 vip_agent SetEnvIf User-Agent ^VipAgent2 vip_agent Order Allow,Deny Allow from env=vip_agent AuthType Basic AuthName "Protected Login" AuthUserFile /path/to/htpasswd Require valid-user Satisfy any
另外,为了这个工作,需要确保在httpd.conf中启用了mod_rewrite , mod_authn_file和mod_setenvif ,并且在这里设置了这个指令:
AllowOverride All
此configuration允许访问具有启动“VipAgent1”和“VipAgent2”的用户代理的请求,但要求所有其他访问者的authentication凭证。