IIS htaccess rule converter only importing 1 rule

我怕爱的太早我们不能终老 提交于 2019-12-31 06:13:30

问题


I have a example .htaccess file (found here) with bad robots to block. Here's a small sample code block from that file:

#bad bots start
#programmed by tab-studio.com public  version 2017.12
#1 new rule every 500 entries
RewriteCond %{HTTP_USER_AGENT} \
12soso|\
192\.comagent|\
1noonbot|\
zuibot|\
zyborg|\
zyte\
 [NC]
RewriteRule .* - [F]
#bad bots end

Basically throwing a 403 on a URL match. I checked this post to see how I can convert these .htaccess rules to a web.config rewrite rule via IIS. When I import the rules however, I get an unexpected result where no rules seem to be converted, see image below. What am I doing wrong?


回答1:


It's certainly choking on the \ and the carriage return. If you try the following you'll see it should import properly:

#bad bots start
#programmed by tab-studio.com public  version 2017.12
#1 new rule every 500 entries
RewriteCond %{HTTP_USER_AGENT} 12soso|192\.comagent|1noonbot|zuibot|zyborg|zyte
 [NC]
RewriteRule .* - [F]
#bad bots end

Having said that, you might consider looking at using Request Filtering & Scan Headers instead: https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/filteringrules/filteringrule/scanheaders/



来源:https://stackoverflow.com/questions/55609110/iis-htaccess-rule-converter-only-importing-1-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!