IIS UrlRewrite - 仅存在一个实际文件

时间:2012-05-12 22:18:23

标签: iis url-rewrite-module

我的web.config中有以下url重写代码

我想将任何.htm转发给brand.aspx。

所以如果有人输入

test1.htm

test2.htm

test3.htm

会去brand.aspx。但是,如果服务器中存在实际文件调用“test1.htm”,则以下url重写将起作用,然后它将重定向到brand.aspx。如果没有文件存在,它将只返回404而不是重定向到brand.aspx。有人知道为什么吗?非常感谢。

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="test" stopProcessing="false">
<match url="(.*)\.htm$" ignoreCase="true" /> 
<action type="Rewrite" url="brand.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

1 个答案:

答案 0 :(得分:0)

有一个类似的主题 Using a custom URL rewriter, IIS6, and urls with .htm, .html, etc

之前我遇到过类似的问题,我做了一个自定义的IHTTPModule

我在

使用了指南

http://msdn.microsoft.com/en-us/library/ms227673.aspx