通过 IIS URL 重写模块向所有 URL 添加尾部斜杠已广泛传播,但是如何为以 .html 和 .aspx 结尾的 URL 添加例外?
今天我有这个:
<rule name="Add trailing slash" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<!-- Doesn't seem to be working -->
<!--<add input="{REQUEST_URI}" pattern="(.*?).html$" negate="true" />-->
<!--<add input="{REQUEST_URI}" pattern="(.*?).aspx$" negate="true" />-->
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}/" />
</rule>