1.安装 URL重写 模块
下载 rewrite_amd64_zh-CN.msi
并安装
2.新建规则
打开URL重写->添加规则->空白规则
3.名称
填入 http2https
4.匹配URL
模式填入 (.*)
5.条件->添加
条件输入 {HTTPS}
检查输入字符串是否选择 与模式匹配
模式 ^OFF$
6.操作
操作类型选择 重定向
重定向URL填入https://{HTTP_HOST}/{R:1}
重定向类型选择 永久(301)
7.保存
点击应用保存规则
8.配置文件
web.config会增加rewrite节点如下
<rewrite>
<rules>
<rule name="http2https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>