我在Windows 7 RC上使用IIS 7.5。我使用IIS Url Rewrite模塊來重寫URL。具有URL重寫模塊的IIS 7.5在Postback上加倍QueryString Params
似乎一切正常,直到我通過單擊按鈕執行回發。然後,追加查詢字符串PARAMS我重寫URL,就像這樣:
重寫後的URL,因爲它出現在瀏覽器: http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike
沒有URL重寫URL是:
http://localhost/product.aspx?lang=en&id=1239&title=Gary+Fisher+Hkek+Mountain+Bike
當我點擊一個按鈕來執行回發時,URL更改爲:
而當URL重寫,所有的查詢字符串PARAMS增加一倍 - 所以,當我想這樣做是爲了獲得當前語言:
Request.QueryString["lang"]
我回來的值是「恩,恩」。
其他人有這些問題嗎?
UPDATE:從程序Web.Config
重寫規則<rule name="RedirectProductPageUrls" stopProcessing="true">
<match url="^product\.aspx$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" />
<add input="{QUERY_STRING}" pattern="^lang=([^=&]+)&id=([^=&]+)&title=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/products/{C:2}/{C:3}" appendQueryString="false" redirectType="Permanent" />
</rule>
<rule name="RewriteProductPageUrls" stopProcessing="true">
<match url="^([^/]+)/product/([^/]+)/([^/]+)/?$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="product.aspx?lang={R:1}&id={R:2}&title={R:3}" />
</rule>
你可以發佈你的重寫規則嗎?只需發佈web.config中的任何內容: ... –
2009-07-21 20:10:35
已更新,其中包含重寫規則和產品頁面的重定向規則。 – MartinHN 2009-07-24 10:53:27