【问题标题】:Redirect website from http to https将网站从http重定向到https
【发布时间】:2013-07-01 16:58:51
【问题描述】:

我有一个存储在 azure 上的网站,我为此获得了 SSL 证书。我正在尝试将 www.mywebsite.com 重定向到 https://www.mywebsite.com,但没有成功。

我正在使用以下代码来更改部署我的项目的 IIS 的配置:

<system.webServer>
<rewrite>
  <rules>
    <rule name="Redirect to HTTPS">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        <add input="{URL}" pattern="/$" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      </conditions>
      <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
    </rule>
  </rules>
</rewrite>

但是当我输入我的 URL 时,它不会重定向到 https。

顺便说一句,重写似乎无法被 Intellisense 识别。

【问题讨论】:

标签: c# iis azure


【解决方案1】:

我可以看到您已从Steve Marx example 获取代码片段

问题是您的规则名称中有空格。只需删除它们即可。

规则的name属性不能有空格;该规则在名称中有空格的 Azure 上的 IIS 中无法正常工作。

在此处查找完整文章: Azure https guide

【讨论】:

    猜你喜欢
    • 2013-07-03
    • 1970-01-01
    • 2017-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多