【发布时间】:2016-04-14 00:17:54
【问题描述】:
我正在尝试设置 IIS 重写规则以将“.html”添加到没有扩展名的 URL,例如:
原网址:www.domain.com/page
重写为: www.domain.com/page.html
我想忽略任何带有扩展名的 URL(例如,如果它们是图像或其他文件)
有人知道我需要设置的规则吗?
【问题讨论】:
标签: asp.net iis url-rewriting
我正在尝试设置 IIS 重写规则以将“.html”添加到没有扩展名的 URL,例如:
原网址:www.domain.com/page
重写为: www.domain.com/page.html
我想忽略任何带有扩展名的 URL(例如,如果它们是图像或其他文件)
有人知道我需要设置的规则吗?
【问题讨论】:
标签: asp.net iis url-rewriting
我自己通过修改另一个网站上的规则来解决这个问题:
<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>
【讨论】: