简体   繁体   English

iis 7.5 url重写-不处理百分比'%'符号

[英]iis 7.5 url rewrite -not processing percent '%' symbol

I imported rules from IIRF into IIS URL Rewrite, and most seemed to work fine. 我从IIRF将规则导入到IIS URL Rewrite中,并且大多数看起来工作正常。 I just noticed tho that some urls have percent symbols in them (trying to redirect some bad inbound links, with percent encoded characters in them). 我刚刚注意到,有些网址中包含百分比符号(试图重定向一些不良的入站链接,其中包含百分比编码字符)。 The regex seems to not work when the percent is in there, so I assume it is trying to interpret is as a command or something. 当百分比在其中时,正则表达式似乎不起作用,因此我认为它试图将其解释为命令或其他内容。 Can't find any documentation on this, anyone know? 没人知道吗?

The accepted answer didn't work in my case, but I discovered a different way to setup the rewrite rule. 对于我来说,可接受的答案不起作用,但是我发现了另一种设置重写规则的方法。 This will do a 301 redirect. 这将执行301重定向。

Requested URL: http://www.shuttercontractor.com/m/vinyl-%E2%80%8Bshutters.aspx 要求的网址: http : //www.shuttercontractor.com/m/vinyl-%E2%80%8Bshutters.aspx
Target URL: http://www.shuttercontractor.com/m/vinyl-shutters.aspx 目标网址: http : //www.shuttercontractor.com/m/vinyl-shutters.aspx

<rule name="301 Redirect to vinyl shutters category" stopProcessing="true">
    <match url="." ignoreCase="false" />
    <action type="Redirect" redirectType="Permanent" url="m/vinyl-shutters.aspx" />
    <conditions>
        <add input="{UNENCODED_URL}" pattern="m/vinyl-%[Ee]2%80%8[Bb]shutters\.aspx" ignoreCase="false" />
    </conditions>
</rule>

Basically, the match will work on any URL, and we use a condition with the UNENCODED_URL server variable to ensure the pattern matches before redirecting. 基本上,匹配可以在任何URL上进行,并且我们将条件与UNENCODED_URL服务器变量一起使用,以确保模式在重定向之前匹配。

appears that the rewrite rules already undo the url encoding, so it no longer sees a %3E as that, but instead as a '<'.. so using a > in place of %3E does the trick. 似乎重写规则已经撤消了url编码,因此它不再将%3E视为那样,而是将其视为“ <” ..因此,使用>代替%3E可以解决问题。 Now, to go fix a bunch of urls. 现在,要修复一堆网址。 argh.

Edit: 编辑:

Also, if you hand edit the web.config (versus using the UI editor), you will need to use & lt ; 另外,如果您手动编辑web.config(相对于使用UI编辑器),则需要使用&lt; for the < symbols. 为<符号。 It's probably best to use the UI to avoid confusion. 最好使用UI以避免混淆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM