0

我无法让这部分 htaccess 工作:


RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_USER_AGENT} ^(360Spider|acoon|ahrefs|aihit|altushost|amazon|archive|airjordanin|applecreek|baidu|bezeqint|bilbo|bork|botje|butterfly|buy) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(catchbot|career|cloud-ips|coach|contabo|corbina) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(dataprovider|digext|discobot|dotbot|ec2|edisterBot|energis|ephorus|exabot|exigen|ezooms|fastlink|genieo|huaweiSymantecSpider) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(iguana|ileadz|ipxserver|jaunty|jadynave|jikespider|keywordspy|kimsufi|kobala|komodiabot|koula|longchamp) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(magpie|majestic12|malas|Media|michael|MJ12bot|modx|mohitseo|MOR306|mulberryoculos) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(nashirnet|ncsa|netwiz|obot|openindex|osso|panscient|pathcom|PeoplePal|piki|presto|purity) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(santrex|scoutjet|shabnet|sistrix|siteexplorer|softlayer|sogou|sosospider|Spinn3r|splims|statsbot|survey) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(tangoo|targetdevelopmentdirect|thunderstone|trabajoo|track|trellian|trendictionbot|turnitinBot|TweetmemeBot|ukraine) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(vagabondo|vanekeris|vectranet|webcijfers|wise|yabrowser|yandex|yodao|zh-CN) [NC]

# ISSUE 403 / SERVE ERRORDOCUMENT
RewriteRule . - [F,L]

开始时也没有 ^ ,最后没有 $ 但机器人仍然来,关于我在 php 中的统计信息 也尝试了Referer,Host和FORWARDED而不是HTTP_USER_AGENT,以及remote_address的数字。

有什么帮助吗?

4

1 回答 1

0

到目前为止,这条规则看起来不错,尽管我会改变两件事。

  • 从规则中排除robots.txt,因为其中许多都遵守机器人排除标准。添加

    RewriteCond %{REQUEST_URI} !^/robots.txt$
    

    然后robots.txt用一组有意义的规则填充。如果要排除所有机器人

    User-agent: *
    Disallow: /
    
  • 更改.^,因为主页尚未包含在此规则中

    RewriteRule ^ - [F]
    
于 2013-04-19T22:37:32.710 回答