实现例如:输入域名http://ssldun.cn自动变成https://www.ssldun.cn

1、安装ssl证书。

Server2016-1-1.png

2、导入相关证书

Server2016-1-2.png

3、进入相关网站,绑定HTTPS主机头到网站。(需要服务器名字指示打对勾,不然提示冲突)

Server2016-1-3.png

4、安装URL重写工具。

Server2016-1-4.png

5、在想要跳转的网站上,双击“url 重写”

Server2016-1-5.png

6、添加空白规则

Server2016-1-6.png

7、添加url规则
名称:http to https
模式:(.*)
展开条件

Server2016-7.png

8、继续添加URL规则
添加条件
条件输入:{HTTPS}
模式:^OFF$

Server2016-8.png9、继续添加URL规则
操作类型:重定向
重定向URL:https://{HTTP_HOST}/{R:1}
重定向类型:已找到(302) 或 参阅其它(303)

Server2016-9.png

10、最后一步,应用

Server2016-10.png

 

以上方式比较繁琐,也可以参考如下简单方式进行配置

根据IIS版本备份以下文件:

IIS6.0 路径:C:/WINDOWS/Help/iisHelp/common/403-4.htm

IIS7.0以上 路径:C:/inetpub/custerr/zh-CN/403.htm

 

403webconfig.zip 点前面链接直接下载403.htm和web.config页面

把以下内容全部拷贝替换(403-4或403)里面所有内容,保存即可

  <HTML><HEAD><TITLE>该页必须通过安全通道查看</TITLE>

 <META HTTP-EQUIV="Content-Type" Content="text/html; charset=GB2312">

 </HEAD><BODY>

<script type="text/javascript">  
    var url=window.location.href;  
    url=url.replace("http:","https:")  
    window.location.replace(url);</script>

 </BODY></HTML>

 

IIS6中,站点属性-》目录安全性-》编辑中把“要求安全通道(SSL)”勾选上即可。IIS7、IIS8中,SSL设置-》把“要求SSL”勾选即可。

 

 

2.对于asp.net站点,可以直接修改web.config配置文件:

<?xml version="1.0" encoding="utf-8"?><configuration>
  <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></configuration>

 

此文章对您是否有帮助? 0 用户发现这个很有用 (0 投票)