【问题标题】:IIS rewrite - add '.html' to any URL's that don't have an extensionIIS 重写 - 将“.html”添加到任何没有扩展名的 URL
【发布时间】:2016-04-14 00:17:54
【问题描述】:

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

原网址:www.domain.com/page

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

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

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

【问题讨论】:

    标签: asp.net iis url-rewriting


    【解决方案1】:

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

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 2011-08-10
      • 2022-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多