【问题标题】:Redirect from https to http in Azure Web App service在 Azure Web App 服务中从 https 重定向到 http
【发布时间】:2017-02-04 21:56:40
【问题描述】:

我有一个同时支持 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>

【问题讨论】:

    标签: http azure redirect iis https


    【解决方案1】:

    Azure 应用服务网站支持 IIS URL 重写模块,因此您尝试执行的操作应该有效。我认为你唯一弄错的是条件,你正在为Server Variable 添加一个名为HTTP 的条件,但是没有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> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2016-12-29
      • 1970-01-01
      • 2012-10-05
      • 2021-03-01
      相关资源
      最近更新 更多