代码之家  ›  专栏  ›  技术社区  ›  Beau D'Amore

用于将尾部斜杠添加到主页的Azure IIS重写规则

  •  0
  • Beau D'Amore  · 技术社区  · 4 年前

    我有一个在PAAS中运行的Sitecore web应用程序。我有两个url重写规则

    1. 不在时加前缀“www”

    除了主页以外,其他地方都可以使用。 只有主页必须用斜杠。 我觉得忽略目录的情况可能就是问题所在。我们没有目录可供访问,只有网页。

    以下是我所拥有的:

    <rewrite>
      <rules>
        <rule name="Redirect to www">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^OURDOMAIN.com$" />
          </conditions>
          <action type="Redirect" url="https://www.OURDOMAIN.com/{R:0}" />
        </rule>
        <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" />
          </conditions>
          <action type="Redirect" url="{R:1}/" />
        </rule>
      </rules>
    </rewrite>
    

    www.OURDOMAIN.com

    0 回复  |  直到 4 年前