SetEnvIfNoCase重定向 [英] SetEnvIfNoCase redirection
问题描述
大家好,我一直在使用 SetEnvIfNoCase User-Agent
和通配符来学习通配符方法,
但使用下面的示例。仅提供403错误页面如果useragent与通配符匹配。
,但是我想要的是将 user-agent重定向到另一个网站,例如黑洞或垃圾邮件页面。
使用类似 RewriteRule ^(。*)$ http://发送垃圾到这里/
Hi all ive been learning wildcard methods using SetEnvIfNoCase User-Agent
and wildcards,
But using the example below.only serves a 403 error page if a useragent matches the wildcards.
but what i want is to redirect the "user-agent" to another website such as a black hole or spam page.
using something like RewriteRule ^(.*)$ http://send junk to here/
SetEnvIfNoCase User-agent "(B2|Bac|Bad|Bag|Bai|Bast|Batch|Bing|Bite|Bla|Blex)" bad_bot=yes
#
Order Allow,Deny
Allow from All
Deny from env=bad_bot
我可以替换来自env = bad_bot
的拒绝,以使其重定向到所需的网站,而不是提供403错误页面。
what can i replace the Deny from env=bad_bot
with to make it redirect to the wanted website instead of serving the 403 error page.
推荐答案
在您的 DOCUMENT_ROOT / .htaccess
文件中具有这样的重写规则:
Have your rewrite rule like this in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} B2|Bac|Bad|Bag|Bai|Bast|Batch|Bing|Bite|Bla|Blex [NC]
RewriteRule !^spam/ http://officeofstrategicinfluence.com/spam/ [L,NC,R=302]
更新:作为回应,OP
1-添加新的过滤器行,我是否需要更改[NC]?和2-如果我想自己添加一个单词,我是否仍使用RewriteCond%{HTTP_USER_AGENT} ^ word [NC]?与^
尝试以下代码:
RewriteCond %{HTTP_USER_AGENT} B2|Bac|Bad|Bag|Bai|Bast|Batch|Bing|Bite|Bla|Blex [NC,OR]
RewriteCond %{HTTP_USER_AGENT} foo|bar|etc [NC]
RewriteRule !^spam/ http://officeofstrategicinfluence.com/spam/ [L,NC,R=302]
这篇关于SetEnvIfNoCase重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!