zoukankan      html  css  js  c++  java
  • LAMP 2.6 Apache 禁止指定user_agent

    user_agent 我把它叫做浏览器标识, 目前主流的浏览器有 IE、 chrome、 Firefox、 360、 iphone
    上的 Safari、Android 手机上的、百度搜索引擎、google 搜索引擎等很多,每一种浏览器都
    有对应的 user_agent,下面我先发几个 user_agent,帮助大家识别。

    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E; SE2.x)
    
    Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/31.0.1650.63 Safari/537.36
    
    Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)
    
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; WOW64; Trident/4.0; SLCC2;.NET
    
    CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC6.0; .NET4.0C; .NET4.0E; InfoPath.3; 360SE)

    上面这些都是常见的 user_agent。这一小节主要针对这些 user_agent 来做一些限制。
    配置如下:

    <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{HTTP_USER_AGENT} ^*curl* [NC,OR]
     RewriteCond %{HTTP_USER_AGENT} ^*chrome* [NC]
      RewriteRule .* - [F]
    </IfModule>

    ^*curl* 包含curl的user_agent禁掉。 [NC]不区分大小写 [OR]和

    重启配置文件用谷歌浏览器或者curl访问这个论坛,就会403

  • 相关阅读:
    Spring 中各种通知
    Spring 中的注解
    Spring_DI利用set方法赋值Demo
    Beta冲刺总结
    用户使用调查报告
    Beta(7/7)
    Beta(6/7)
    Beta(5/7)
    Beta(4/7)
    Beta(3/7)
  • 原文地址:https://www.cnblogs.com/wangshaojun/p/5034704.html
Copyright © 2011-2022 走看看