由useragent或空引用块阻止

时间:2022-08-20 11:18:24

A stranger bot (GbPlugin) is codifying the urls of the images and causing error 404.
I tried to block the bot without success with this in the bottom of my .htaccess, but it didn't work.

一个陌生人机器人(GbPlugin)正在编纂图像的网址并导致错误404.我试图阻止机器人在我的.htaccess底部没有成功,但它没有用。

Options +FollowSymlinks  
RewriteEngine On  
RewriteBase /  
RewriteEngine on  
RewriteCond %{HTTP_REFERER} !^$  
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]  
RewriteCond %{HTTP_USER_AGENT} ^GbPlugin [NC]  
RewriteRule .* - [F,L]     

The log this below.

记录如下。

201.26.16.9 - - [10/Sep/2011:00:06:05 -0300] "GET /wp%2Dcontent/themes/my_theme%2Dpremium/scripts/timthumb.php%3Fsrc%3Dhttp%3A%2F%2Fwww.example.com%2Fwp%2Dcontent%2Fuploads%2F2011%2F08%2Fmy_image_name.jpg%26w%3D100%26h%3D65%26zc%3D1%26q%3D100 HTTP/1.1" 404 1047 "-" "GbPlugin"

Sorry for my language mistakes

对不起我的语言错误

3 个解决方案

#1


23  

Here's what you can put in your .htacces file

这是您可以放在.htacces文件中的内容

Options +FollowSymlinks  
RewriteEngine On  
RewriteBase /  
SetEnvIfNoCase Referer "^$" bad_user
SetEnvIfNoCase User-Agent "^GbPlugin" bad_user
SetEnvIfNoCase User-Agent "^Wget" bad_user
SetEnvIfNoCase User-Agent "^EmailSiphon" bad_user
SetEnvIfNoCase User-Agent "^EmailWolf" bad_user
SetEnvIfNoCase User-Agent "^libwww-perl" bad_user
Deny from env=bad_user

This will return:

这将返回:

HTTP request sent, awaiting response... 403 Forbidden
2011-09-10 11:15:48 ERROR 403: Forbidden.

#2


2  

May I recommend this method:

我可以推荐这种方法:

Put this is .htaccess in root of your site.

把它作为你网站的根目录中的.htaccess。

ErrorDocument 503 "Your connection was refused"
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^(Mozilla.*537.36|Mozilla.*UCBrowser\/9.3.1.344)$ [NC]
RewriteRule .* - [R=503,L]

Where

哪里

^(Mozilla.*537.36|Mozilla.*UCBrowser\/9.3.1.344)$

are the two useragents I wanted to block in this example case.

是我想在这个案例中阻止的两个用户。

You can use regex so a useragent like

你可以使用正则表达式这样的使用者

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0

could be

可能

Mozilla.*Firefox\/40.0

^means match from beginning and $ to the end so you could block just one useragent with:

^表示从开头和$到最后匹配,因此您可以阻止一个useragent:

ErrorDocument 503 "Your connection was refused"
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*Firefox\/40.0$ [NC]
RewriteRule .* - [R=503,L]

Or add several using the | character to separate them inside ( and ) like in the first example.

或使用|添加几个在第一个例子中将内部(和)分开的字符。

RewriteCond %{HTTP_USER_AGENT} ^(Mozilla.*537.36|Mozilla.*UCBrowser\/9.3.1.344)$ [NC]

You can test it by putting your useragent in the code and then try to access the site. http://whatsmyuseragent.com/

您可以通过将您的useragent放入代码中然后尝试访问该站点来测试它。 http://whatsmyuseragent.com/

#3


0  

To block empty referers, you can use the following Rule :

要阻止空引用,可以使用以下规则:

RewriteEngine on

RewriteCond %{HTTP_REFERER} ^$
RewriteRule ^ - [F,L]

This will forbid all requests to your site if HTTP_REFERER value is empty ^$ .

如果HTTP_REFERER值为空^ ^,这将禁止对您站点的所有请求。

To block user agents, you can use

要阻止用户代理,您可以使用

RewriteEngine on

RewriteCond %{HTTP_USER_AGENT} opera|firebox|foo|bar [NC]
RewriteRule ^ - [F,L]

This will forbid all requests to your site if HTTP_USER_AGENT matches the Condition pattern.

如果HTTP_USER_AGENT与条件模式匹配,这将禁止对您站点的所有请求。

#1


23  

Here's what you can put in your .htacces file

这是您可以放在.htacces文件中的内容

Options +FollowSymlinks  
RewriteEngine On  
RewriteBase /  
SetEnvIfNoCase Referer "^$" bad_user
SetEnvIfNoCase User-Agent "^GbPlugin" bad_user
SetEnvIfNoCase User-Agent "^Wget" bad_user
SetEnvIfNoCase User-Agent "^EmailSiphon" bad_user
SetEnvIfNoCase User-Agent "^EmailWolf" bad_user
SetEnvIfNoCase User-Agent "^libwww-perl" bad_user
Deny from env=bad_user

This will return:

这将返回:

HTTP request sent, awaiting response... 403 Forbidden
2011-09-10 11:15:48 ERROR 403: Forbidden.

#2


2  

May I recommend this method:

我可以推荐这种方法:

Put this is .htaccess in root of your site.

把它作为你网站的根目录中的.htaccess。

ErrorDocument 503 "Your connection was refused"
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^(Mozilla.*537.36|Mozilla.*UCBrowser\/9.3.1.344)$ [NC]
RewriteRule .* - [R=503,L]

Where

哪里

^(Mozilla.*537.36|Mozilla.*UCBrowser\/9.3.1.344)$

are the two useragents I wanted to block in this example case.

是我想在这个案例中阻止的两个用户。

You can use regex so a useragent like

你可以使用正则表达式这样的使用者

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0

could be

可能

Mozilla.*Firefox\/40.0

^means match from beginning and $ to the end so you could block just one useragent with:

^表示从开头和$到最后匹配,因此您可以阻止一个useragent:

ErrorDocument 503 "Your connection was refused"
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*Firefox\/40.0$ [NC]
RewriteRule .* - [R=503,L]

Or add several using the | character to separate them inside ( and ) like in the first example.

或使用|添加几个在第一个例子中将内部(和)分开的字符。

RewriteCond %{HTTP_USER_AGENT} ^(Mozilla.*537.36|Mozilla.*UCBrowser\/9.3.1.344)$ [NC]

You can test it by putting your useragent in the code and then try to access the site. http://whatsmyuseragent.com/

您可以通过将您的useragent放入代码中然后尝试访问该站点来测试它。 http://whatsmyuseragent.com/

#3


0  

To block empty referers, you can use the following Rule :

要阻止空引用,可以使用以下规则:

RewriteEngine on

RewriteCond %{HTTP_REFERER} ^$
RewriteRule ^ - [F,L]

This will forbid all requests to your site if HTTP_REFERER value is empty ^$ .

如果HTTP_REFERER值为空^ ^,这将禁止对您站点的所有请求。

To block user agents, you can use

要阻止用户代理,您可以使用

RewriteEngine on

RewriteCond %{HTTP_USER_AGENT} opera|firebox|foo|bar [NC]
RewriteRule ^ - [F,L]

This will forbid all requests to your site if HTTP_USER_AGENT matches the Condition pattern.

如果HTTP_USER_AGENT与条件模式匹配,这将禁止对您站点的所有请求。