简体   繁体   中英

IIS Rewrite URL Decode rule fails

I am trying to convert a url of the structure

http://www.xyxyxh.com/ShowItem.aspx%3FID%3D947 

to

http://www.xyxyxh.com/ShowItem.aspx?ID=947 

I wrote the following url rewrite for IIS 7.5 and above

<rewrite>
  <rules>
    <rule name="Convert" stopProcessing="true">
      <match url="^ShowItem.aspx/(.+)$" />
      <action type="Redirect" url="?q={UrlDecode:{R:1}}" />
    </rule>
  </rules>
</rewrite>

but the rule fails and the url does not convert. Where am I going wrong?

If you check on some url decryption tool for example

http://meyerweb.com/eric/tools/dencoder/

and paste there

http://www.xyxyxh.com/ShowItem.aspx%3FID%3D947

and press decode you will see it's

http://www.xyxyxh.com/ShowItem.aspx?ID=947

So you need something more then simple url rewrite or maybe you don't need it at all as it it the same?

Simple url rewrite module is useful for example to convert

from:

http://localhost/article/342/some-article-title

to:

http://localhost/article.aspx?id=342&title=some-article-title

You can find more details here:

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

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