HTTP redirect 重定向到 HTTPS

最近帮一个顾客做网站,  需要HTTPS.  

之前接触的SSL certificate直接上传到plesk 上面勾选重定向即可.

在此先吐槽下godaddy 服务贵功能还少.

用代码从HTTP来重定向到HTTPS 代码如下

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

只需要把以上代码放到web.config 里面的<configuration>里面即可代码重定向到HTTPS.

猜你喜欢

转载自www.cnblogs.com/TheMiao/p/9643985.html
今日推荐