我注意到必应机器人不遵守robots.txt规则,因为我不允许所有的机器人,但是必应机器人不遵守规则,我用.htaccess阻止一些机器人,有代码阻止所有的机器人吗?
发布于 2019-10-17 09:52:41
所有的机器人都应该被/robots.txt
(而不是.htaccess
)阻塞,如下所示:
# cat robots.txt
User-agent: *
Disallow: /
该文件需要位于文档根目录和世界可读性中。通过在web浏览器中打开它进行检查:http://yourdomain/robots.txt
应该给出文件内容。
从技术上讲,机器人可能选择不遵循这一原则,但实际上应该这样做。是的,我相信。
如果由于某些原因(实际的Bing不太可能),请尝试
# cat .htaccess
SetEnvIfNoCase User-Agent .*bot.* search_robot
SetEnvIfNoCase User-Agent .*bing.* search_robot
SetEnvIfNoCase User-Agent .*crawl.* search_robot
Order Deny,Allow
Deny from env=search_robot
Allow from All
为此您需要启用mod_setenvif
apache模块,请参阅http://www.askapache.com/htaccess/setenvif.html
https://unix.stackexchange.com/questions/546440
复制相似问题