apache -- 利用mod_access通过设置环境变量限制特定用户的访问

来源:互联网 发布:网络作家真实收入排行 编辑:程序博客网 时间:2024/05/22 05:05

apache 的 mod_access模块提供的order,deny,allow指令可以用来限制用户对服务器的访问.比较常用的是根据IP来限制用户对apache的访问,下面举两个根据环境变量进行资源控制的例子.

 

只允许特定浏览器的访问,这个实际使用比较少:

 

BrowserMatch MSIE ie_user

<Directory /abc>

order deny,allow

deny from all

allow from env=ie_user

</Directory>

 

 

限制外来站点对服务器资源的效用,比如图片的盗用.

 

SetEnvIf Referer "abc/.com"  deny_it

<Directory /image>

order allow,deny

allow from all

deny from env=deny_it

</Directory>