IIS重写 - 将“.html”添加到没有扩展名的任何URL

时间:2016-04-14 00:17:54

标签: asp.net iis url-rewriting

我正在尝试设置IIS重写规则,将“.html”添加到没有扩展名的网址,例如:

原始网址 www.domain.com/page

重写为: www.domain.com/page.html

我想忽略任何有扩展名的网址(例如,如果它们是图片或其他文件)

有人知道我需要设置的规则吗?

1 个答案:

答案 0 :(得分:2)

我自己通过修改我在另一个网站上的规则来解决这个问题:

<rule name="rewrite directories to html" stopProcessing="true"> <match url="(.*[^/])$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" pattern="(.*?)\.[a-zA-Z]{1,4}$" negate="true" /> </conditions> <action type="Rewrite" url="{R:1}.html" /> </rule>

相关问题