简体   繁体   中英

IIS URL rewrite rule - query string issue

I have the following URL rewrite rule configured in my web.config file:

<rule name="Test Rule" stopProcessing="true">
  <match url="^$" />
  <conditions>
    <add input="{QUERY_STRING}" pattern=".*item=1|all|none|first.*" />
  </conditions>
  <action type="Rewrite" url="/newsite/test.asp?{C:0}" />
</rule>     

The following source url matches as expected:

http://domainname?item=1

However the query string parameter "item" is duplicated in the rewritten URL ie the resulting query string is "item=1&item=1". I don't know why it is being duplicated. Any ideas?

Thank you

Have you tried adding appendQueryString="false" to the action attribute? Like this:

<rule name="Test Rule" stopProcessing="true">
  <match url="^$" />
  <conditions>
    <add input="{QUERY_STRING}" pattern=".*item=1|all|none|first.*" />
  </conditions>
  <action type="Rewrite" url="/newsite/test.asp?{C:0}" appendQueryString="false" />
</rule>    

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