寶塔 根據訪問協議頭屏蔽爬蟲

nginx在站點的設置,配置文件中 server{ } 中添加

 #禁止爬蟲工具的抓取
    if ($http_user_agent ~* "Bytespider|FISPIDER|YisouSpider") {
      return 403;
    }

Appache:
在僞靜態裏設置 這裏以thinkphp爲例!

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
 #禁止爬蟲工具的抓取
RewriteCond %{HTTP_USER_AGENT} "^.*FISPIDER.*|.*YisouSpider.*$" [NC]
RewriteRule ^(.*)$ - [R=404,L]

</IfModule>

配置完不用重啓,就能生效!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章