[英]URL Rewrite and IIS Express: some rules work, some don't
我正在使用IIS Express開發MVC 3應用程序,該應用程序正在web.config中進行一些URL重寫。 我有些奇怪,有些規則運行得很好,而有些規則卻失敗了。
例如,這一作品:
<rule name="Remove ETag">
<match serverVariable="RESPONSE_ETag" pattern=".+" />
<action type="Rewrite" value="" />
</rule>
(來源: https : //stackoverflow.com/a/8089525/88709 )
這個沒有(在第二行中給出了Unrecognized attribute 'url'
):
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
(來源: http : //blogs.iis.net/ruslany/archive/2009/04/08/10-url-rewriting-tips-and-tricks.aspx )
根據ScottGu的IIS Express 簡介 ,IIS Express啟用了完整的Web服務器功能集-包括SSL, URL重寫,媒體支持和所有其他IIS 7.x模塊。
我傾向於認為IIS Express附帶的URL Rewrite模塊可能是1.0版本,而不是2.0版本。 所以我安裝了URL Rewrite Module 2.0 ,但是仍然出現相同的錯誤。
有人知道為什么會發生這種情況嗎? 如果有問題,我的設置是Visual Studio 2010 SP1,IIS Express 7.5.1070,ASP.NET MVC 3。
問題是我將<rule>
放在了錯誤的節點上。 “刪除尾部斜杠”規則應該放在<rules></rules>
,但是我錯誤地將其放置在<outboundRules></outboundRules>
(BTW是“刪除ETag”規則的所在)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.