IIS 地址重定向,网站开放http和https,所有请求都重定向为https
安装重定向模块
双击启动,下一步下一步…
双击可以打开新建规则
规则写完后,会在网站根目录生成一个web.config文件,
这个文件可以重复使用的,如果你的其它网站也需要,拷过去根目录就是了
把web.config复制到网站目录下面,改一下里面的"二级目录"名字,如果有的话,如果没有就直接把二级目录删除
如果本来就有web.config文件的,就把我这个web.config里的<system.webServer>节点搬到你原来的配置文件里去
这个配置文件实现的是,把http请求重定向为https请求,也就是 别人访问你的网站始终会是https
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTPS_HOST}" pattern="^(localhost)" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/二级路径/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
iis url重写模块下载
链接: https://pan.baidu.com/s/1ig3esFUhm7XTZHk35t9FKw 提取码: 2fne