如何让SSL安装完后,HTTP转HTTPS或者HTTPS降回HTTP

这边是以Window Server为架构

前置作业
1.你要有申请SSL凭证,并安装到Server
2.你的IIS的扩充模组安装URL Rewrite

当以上前置作业都完成,就可以到web.config档里面,设定转址规则啰~

以下就你想将HTTP协定转成HTTPS的做法

<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="Found" url="https://{HTTP_HOST}/{R:1}" />    </rule>  </rules></rewrite>

当然如果你觉得不想再付凭证费了,也是可以降回HTTP协定,但是在到期之前,就要先下转回的规则唷
否则你在搜寻引擎的网站列出,连结的网址在还没有变回HTTP协定以前,点过去都会出现凭证错误的警告唷

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

纪录...


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章