不必要地将HTTPS重定向到HTTP并返回HTTPS

时间:2019-03-12 23:52:03

标签: http redirect https web-config

我无法解决我的Web应用程序的重定向问题。输入example.com裸露的网址后,它将重定向到https,http和https。我正在尝试限制重定向的数量,并使站点从https://example.comhttps://www.example.com,中间没有http。

<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Redirect to www" stopProcessing="true">
              <match url="(.*)" />
              <conditions trackAllCaptures="true">
                <add input="{CACHE_URL}" pattern="^(.+)://" />
                <add input="{HTTP_HOST}" pattern="^example\.com$" />
              </conditions>
              <action type="Redirect" url="{C:1}://www.example.com/{R:1}" />
            </rule>
            <rule name="Rewrite to index.php">
                <match url="index.php|images|test.php" />
                <action type="None" />
            </rule>
            <rule name="Rewrite CI Index">
                <match url=".*" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|txt|xml" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php/{R:0}" />
            </rule>
            <rule name="LowerCaseRule1" stopProcessing="true">
                <match url="[A-Z]" ignoreCase="false" />
                <action type="Redirect" url="{ToLower:{URL}}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

screenshot of my redirect problem

0 个答案:

没有答案