基于位置的Apache身份validation要求

我想configuration我的Apache服务器有以下规则。 如果请求来自192.168。 ,不需要authentication。 但是从其他地方,我想要求他们login。

到目前为止,我已经configuration了第二部分:

别名/下载“D:/下载”
 <目录“D:/下载”>
    选项所有索引
     AllowOverride AuthConfig
    全部允许
     AuthType基本
     AuthName“限制文件”
     AuthUserFile D:/Webserver/apache_auth_files/.htpasswd-users
    要求用户myuser_name
 </目录>

但是,如何在规则中创build一个允许192.168的exception。 不需要authentication?

你在找什么是Satisfy Any – 它允许访问,如果有人符合IP ACL Require指令,他们不必同时满足,所以IP范围以外的用户必须进行身份validation,但内部的用户做不。

尝试这个:

 Alias /Downloads "D:/Downloads" <Directory "D:/Downloads"> Options All Indexes AllowOverride AuthConfig Satisfy Any Order deny,allow Deny from all Allow from 192.168.0.0/16 AuthType Basic AuthName "Restricted Files" AuthUserFile D:/Webserver/apache_auth_files/.htpasswd-users Require user myuser_name </Directory>