gpt4 book ai didi

http - URL 重写 web.config 位置 https

转载 作者:可可西里 更新时间:2023-11-01 16:40:48 26 4
gpt4 key购买 nike

我想将我的外联网站点重定向到 https 我有以下 web.config 规则:

 <location path="." inheritInChildApplications="false">
<system.webServer>
<rewrite>
<rules>

<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" `enter code here`ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}"
redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>

问题来了,因为我的服务器上托管了几个子服务,我不希望它们也重定向,我只想重定向站点而不是服务。

最佳答案

执行此操作的一种方法是默认重定向到 HTTPS,但指定的文件夹列表除外。在下面的示例中,文件夹 /service1//service2/ 被排除在重定向之外。其他一切都转到 HTTPS。

<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<!-- avoid redirection for the following paths -->
<add input="{PATH_INFO}" pattern="^/service1/" ignoreCase="true" negate="true" />
<add input="{PATH_INFO}" pattern="^/service2/" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>

关于http - URL 重写 web.config 位置 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41334395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com