简体   繁体   中英

iis 7.5 url rewrite -not processing percent '%' symbol

I imported rules from IIRF into IIS URL Rewrite, and most seemed to work fine. 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.

Requested URL: http://www.shuttercontractor.com/m/vinyl-%E2%80%8Bshutters.aspx
Target URL: 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.

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. 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 ; for the < symbols. It's probably best to use the UI to avoid confusion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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