2015-04-27 84 views
1

我在我的web.config文件中配置以下URL重写规则:IIS URL重写规则 - 查询字符串问题

<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>  

下面的源URL预期相符:

http://domainname?item=1 

然而,查询字符串参数“item”在重写的URL中被复制,即得到的查询字符串是“item = 1 & item = 1”。我不知道它为什么被重复。有任何想法吗?

谢谢

回答

0

您是否尝试过加入appendQueryString="false" action属性?像这样:

<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>