2015-04-27 83 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>