iis8使用url2.0模块实现http跳转到https

第一步安装,url 2.0重写模块

 

点击右键选择》获取新的web平台组件

找到url 重写工具2.0并安装

 

url重写安装成功

 

注意:如果点击无法打开此平台,需要点击链接安装https://www.iis.net/downloads/microsoft/web-platform-installer 即可

 

 

 

web.config 配置如下: 

 

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

 

  如果不想配置,可以修改下,把这段代码放入web.config中。可以实现用户输入主域名和二级域名直接跳转到https协议的域名地址。

 

posted @ 2017-07-01 10:52  fogwu  阅读(5002)  评论(0编辑  收藏  举报