【问题标题】:IIS Rewrite Removing H from HTTPSIIS 重写从 HTTPS 中删除 H
【发布时间】:2018-12-24 21:28:49
【问题描述】:

我遇到了 IIS 网址重写问题。在第一条规则之后一切似乎都很好,但是传递给第二条规则的 url 在架构上没有“h”。我有一个踪迹,进来的网址是:

产品/car.aspx

然后通过下面的第一条规则:

https://fo.bar.com/product/car.aspx

但是接下来的规则是在 url 中传递的:

ttps://fo.bar.com/product/car.aspx

对此有任何想法都会很棒。以下是我在 web.config 中的规则

<system.webServer>
    <rewrite>
        <clear />
        <rule name="HTTP to HTTPS" stopProcessing="false">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAll">
                <add input="{HTTPS}" pattern="^OFF$" />
                <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true" />
                <add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true" />
            </conditions>
            <action type="Rewrite" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
        <rule name="Remove incorrect first char from query string" enabled="false" stopProcessing="true">   
            <match url="(.*)"/>
            <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                <add input="{QUERY_STRING}" pattern="^\&amp;(.*)"/>
            </conditions>
            <action type="Rewrite" url="{R:0}?{C:1}" appendQueryString="false"/>
        </rule>
        ..................

【问题讨论】:

    标签: asp.net-mvc iis url-rewriting


    【解决方案1】:

    从问题看来,您想要做的只是将所有 HTTP 流量重定向到 HTTPS?

    如果是这样,您可以将规则简化为:

                <rule name="HTTP to HTTPS" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTPS}" pattern="off" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
                </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-23
      • 2017-10-30
      • 1970-01-01
      • 2012-02-28
      • 2011-02-06
      • 1970-01-01
      • 2016-03-20
      • 2021-06-05
      相关资源
      最近更新 更多