繁体   English   中英

IIS重写从HTTPS删除H

[英]IIS Rewrite Removing H from HTTPS

我遇到了IIS网址重写问题。 在第一个规则之后一切似乎都很好,但是随后传递给第二个规则的url在模式上没有'h'。 我有一个痕迹,出现的URL是:

产品/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>
        ..................

从这个问题看来,您要做的就是将所有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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM