繁体   English   中英

将网站从http重定向到https

[英]Redirect website from http to https

我在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识别。

我可以看到您已经摘取了Steve Marx示例中的代码片段

问题是您的规则名称中包含空格。 只需删除它们,它将起作用。

规则的名称属性不得包含空格; 该规则在名称中带有空格的Azure上的IIS中将无法正常工作。

在此处查找完整的文章: Azure https指南

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM