[英]How can I block a Bot with .htaccess
Im having problems with bot* and *bot. 我在bot *和* bot方面遇到问题。 I have limited knowledge of .htaccess but have been blocking bots with .htaccess rules below.
我对.htaccess的了解有限,但是一直在使用以下.htaccess规则阻止漫游器。
My question is in 2 parts: 我的问题分为两个部分:
*
bot and bot *
*
bot和bot *
的正确语法? Many thanks in advance 提前谢谢了
#Enable RewriteEngine
RewriteEngine On
# Stop the Nasties!!
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR]
RewriteCond %{HTTP_USER_AGENT} baiduspider [NC,OR]
RewriteCond %{HTTP_USER_AGENT} baidu [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Baiduspider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Baiduspider* [OR]
RewriteRule ^.* - [F,L]
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
Yes, it is right way... 是的,这是正确的方法...
And, if you want to block any IP, then as an example: 并且,如果您要阻止任何IP,请以以下示例为例:
Order Deny,Allow
Deny from 127.0.0.1
You can combine all those conditions into one as: 您可以将所有这些条件合并为:
RewriteCond %{HTTP_USER_AGENT} (autoemailspider|baidu) [NC]
RewriteRule ^ - [F]
NC
is for ignore case. NC
是忽略情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.