【问题标题】:Web.config rewrite rule http to https and angular route combinationWeb.config 将规则 http 重写为 https 和角度路由组合
【发布时间】:2021-08-04 06:57:33
【问题描述】:

我在 IIS 中有以下针对 Angular 应用程序的重写规则:

<rewrite>
    <rules>
        <rule name="Angular Routes1" enabled="true" stopProcessing="true">
            <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="index.html" />
        </rule>
        <rule name="HTTPS Redirect" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTPS}" pattern="^OFF$" />
            </conditions>
            <action type="Redirect" url="https://www.example.com{REQUEST_URI}" appendQueryString="false" />
        </rule>
    </rules>
</rewrite>

当有人浏览http://www.example.com时,它被重定向到https://www.example.com,但是当我使用设置网站的路由时,例如:

http://www.example.com/layout/dark 没有重定向到https://www.example.com/layout/dark

我想知道我添加两条规则时是否出错,应该全部添加到一条规则中。

谢谢。

【问题讨论】:

    标签: angular iis


    【解决方案1】:

    你可以先把 http 转 https 规则再试。如果还是不行,你可以使用失败请求跟踪来查看详细的错误原因。

    Using Failed Request Tracing to Trace Rewrite Rules.

    【讨论】:

      猜你喜欢
      • 2014-11-04
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 2012-12-29
      • 2012-08-22
      • 1970-01-01
      相关资源
      最近更新 更多