的.htaccess允许所有来自特定用户代理 [英] .htaccess Allow All from Specific User Agent
问题描述
我有一个网站,我开发的,也将被拉到一个Web应用程序。我有以下的code在我的的.htaccess
文件,以prevent访问任何人,是不是对我的允许的IP:
订单拒绝,允许
所有拒绝
AuthName指令限制区域 - 需要授权
的AuthUserFile /home/content/html/.htpasswd
与AuthType基本
需要有效的用户
从12.34.567.89允许
满足任何
问:
我想补充一个从
规则,也将允许特定的HTTP用户代理访问该站点允许。
我发现这个code重定向如果不是用户代理:
RewriteEngine叙述上
的RewriteCond%{HTTP_USER_AGENT}!= myuseragent
重写规则^文件/.*$ / [R = 302,L]
不过,我似乎无法弄清楚如何把它变成一个从
规则允许。帮助?
更新
我发现code以下,以阻止特定用户代理...我反而喜欢说如果没有 myuseragent
,然后阻止。
< IfModule mod_rewrite.c>
SetEnvIfNoCase ^用户代理$ *。(的libwww-perl的| aesop_com_spiderman)HTTP_SAFE_BADBOT
从ENV = HTTP_SAFE_BADBOT拒绝
< / ifModule>
SetEnvIfNoCase用户代理。*谷歌* search_robot
SetEnvIfNoCase用户代理。*雅虎* search_robot
SetEnvIfNoCase用户代理。*僵尸。* search_robot
SetEnvIfNoCase用户代理。*问。* search_robot
订单拒绝,允许
从所有拒绝
从ENV = search_robot允许
的.htaccess SetEnvIf之后和SetEnvIfNoCase例子
I have a website I am developing that is also going to be pulled into a web app. I have the following code in my .htaccess
file to prevent access from ANYONE that is not on my allowed IP:
Order deny,allow
Deny from all
AuthName "Restricted Area - Authorization Required"
AuthUserFile /home/content/html/.htpasswd
AuthType Basic
Require valid-user
Allow from 12.34.567.89
Satisfy Any
QUESTION:
I would like to add an Allow from
rule that will ALSO allow a specific HTTP user agent access to the site.
I found this code to redirect if not the user agent:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !=myuseragent
RewriteRule ^files/.*$ / [R=302,L]
But I can't seem to figure out how to turn this into an Allow from
rule. Help?
UPDATE
I found the code below to block specific user agents... I would instead like to say "if NOT myuseragent
, then block."
<IfModule mod_rewrite.c>
SetEnvIfNoCase ^User-Agent$ .*(libwww-perl|aesop_com_spiderman) HTTP_SAFE_BADBOT
Deny from env=HTTP_SAFE_BADBOT
</ifModule>
SetEnvIfNoCase User-Agent .*google.* search_robot
SetEnvIfNoCase User-Agent .*yahoo.* search_robot
SetEnvIfNoCase User-Agent .*bot.* search_robot
SetEnvIfNoCase User-Agent .*ask.* search_robot
Order Deny,Allow
Deny from All
Allow from env=search_robot
Htaccess SetEnvIf and SetEnvIfNoCase Examples
这篇关于的.htaccess允许所有来自特定用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!