【问题标题】:URL Rewrite not keeping full pathURL重写不保留完整路径
【发布时间】:2018-03-01 22:56:41
【问题描述】:

我正在尝试使用 IIS 8 的 URL 重写模块来确保所有连接都是 https。我无法弄清楚的是如何维护规则的完整路径。我是新手,所以希望这是一个简单的解决方法。

我会转到这样的页面:https://xyz.domain.com/mypath/default.aspx

从“https”中删除“s”后,我被重定向到https://xyz.domain.com/default.aspxmypath 路径消失了。我需要维护它。

这里是 webconfig 条目:

    <rewrite>
    <rules>
        <rule name="Force http to https" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAny">
                <add input="{HTTPS}" pattern="^OFF$" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
    </rules>
</rewrite>

【问题讨论】:

    标签: url url-rewrite-module


    【解决方案1】:

    试试这个:

    <!-- Require HTTPS -->
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
    </rule>
    

    【讨论】:

      【解决方案2】:

      我在网上看了一个例子后遇到了同样的问题。我将重定向 url 更改为 https://{HTTP_HOST}/{REQUEST_URI},它保留了重定向请求中的完整 URL。

      有关参考,请参阅在线文档URL Rewrite Module Configuration Reference

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-09-05
        • 2014-09-18
        • 2012-03-29
        • 2012-03-10
        • 2012-06-23
        • 1970-01-01
        • 1970-01-01
        • 2012-09-14
        相关资源
        最近更新 更多