gpt4 book ai didi

http - 在 Azure Web 应用服务中从 https 重定向到 http

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

我有一个同时支持 HTTP 和 HTTPS(具有有效证书)的网站,但不幸的是,由于某些外部服务的内部问题,HTTPS 配置尚未准备好投入生产。

我现在想通过 IIS(web.config 文件)将每个 https 请求重定向到 http。

我在官方文档中找到了从 http 重定向到 https 的代码,但没有找到相反的代码。所以我尝试转换它,但 IIS 实际上并没有重定向:

<rule name="Redirect to HTTP" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>

最佳答案

Azure 应用服务网站支持 IIS URL 重写模块,因此您尝试执行的操作应该有效。我认为您唯一错误的是条件,您正在为名为 HTTPServer Variable 添加条件,但没有 HTTP ,仅 HTTPSONOFFSee this for full list of IIS Server Variables 。因此,只需翻转它,而不是检查 HTTP 是否已关闭(这不存在且永远不会成立),检查 HTTPS 是否已打开

<rule name="Redirect to HTTP" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>

关于http - 在 Azure Web 应用服务中从 https 重定向到 http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42046083/

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