netnr/ web.config 2020-05-17 08:43
IIS 重写 URL,移除 .html 后缀,依赖 URL Rewrite
<!-- web.config -->

<configuration>
  <system.webServer>
  
    <!-- 移除 .html 后缀 -->
    <rewrite>
      <rules>
        <rule name="RewriteHTML">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="{R:1}.html" />
        </rule>
      </rules>
    </rewrite>

    <!-- HTTP 重定向 HTTPS -->
    <rewrite>
      <rules>
        <rule name="Redirect to https" stopProcessing="true">
          <match url="(.*)"/>
          <conditions>
            <add input="{HTTPS}" pattern="Off"/>
            <add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/>
        </rule>
      </rules>
    </rewrite>

  </system.webServer>
</configuration>

<!--URL Rewrite 下载地址:https://www.iis.net/downloads/microsoft/url-rewrite -->