aw1975
aw1975

Reputation: 1708

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 i.e. the resulting query string is "item=1&item=1". I don't know why it is being duplicated. Any ideas?

Thank you

Upvotes: 1

Views: 496

Answers (1)

Martin Brown
Martin Brown

Reputation: 25310

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>    

Upvotes: 1

Related Questions