Apache 如何阻止爬虫以外的机器人访问我的网站?

Apache 如何阻止爬虫以外的机器人访问我的网站?,apache,security,bots,Apache,Security,Bots,机器人每隔几分钟或几小时就会抓取我的站点,由于资源短缺,我的站点变得不可用。机器人起源于俄罗斯 如何阻止此bot访问我的站点?拒绝指令应位于文件部分,请尝试: <Files 403.shtml> order allow,deny allow from all deny from xxx.xxx.xx.xxx </Files> 我已经解决了这个问题 解决方案: 检查您域的最新访问者 检查持续访问的用户代理 在我的例子中,我发现了YandexBot Mozilla/5.0

机器人每隔几分钟或几小时就会抓取我的站点,由于资源短缺,我的站点变得不可用。机器人起源于俄罗斯


如何阻止此bot访问我的站点?

拒绝指令应位于文件部分,请尝试:

<Files 403.shtml>
order allow,deny
allow from all
deny from xxx.xxx.xx.xxx
</Files>

我已经解决了这个问题

解决方案:

检查您域的最新访问者 检查持续访问的用户代理

在我的例子中,我发现了YandexBot

Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)
现在,您已经找到了减慢服务器速度的bot,请继续并阻止它。您可以使用
robots.txt
.htaccess

.htaccess
方法:

在其中添加以下代码

#block bad bots with a 403
BrowserMatchNoCase "Yandex" bots
Order Allow,Deny
Allow from ALL
Deny from env=bots
User-agent: Yandex
Disallow: /

robots.txt
方法:

在其中添加以下代码

#block bad bots with a 403
BrowserMatchNoCase "Yandex" bots
Order Allow,Deny
Allow from ALL
Deny from env=bots
User-agent: Yandex
Disallow: /

就这样。您已经阻止了bot。

Robots.txt由执行,如果它愿意,并且如果bot具有破坏性,则不太可能麻烦遵守其中的内容。最好在Apache配置和/或iptables或防火墙中进行阻止。