iis 6.0设置实现http转向 https的解决方案

发布时间:2013/10/3 22:03:50 打印 字号:

1、安装证书(不是本文重点,烦请搜索引擎自行查找)

2、“编辑绑定” -->  "添加" -->  "https" and 选择"证书" (其他不需要修改)

3、“SSL设置” --> 勾上“要求SSL”+  客户证书 "忽略"

4、  现在直接访问80会提示 403错误

5、找到 403错误页面,我的在  (C:\inetpub\custerr\zh-CN\403.htm),编辑打开,在<head>标签中加入

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

6、输入不带https就会先跳转到403错误页面,在跳转到https//{HTTP_HOST}/xxx 页面啦!

 

 

补充使用 js 强制 http 到 https

 

<script type="text/javascript">
   var targetProtocol = "https:";    if (window.location.protocol != targetProtocol) window.location.href = targetProtocol +  window.location.href.substring(window.location.protocol.length);</script>

 



首先错误信息(见图一):

2012111916473494510.png

解决方法:

一、验证SSL需要选中的网站(见图二)

1、首先打开所要修改的网站然后右击选择“属性”

2、选择“目录安全性”-->在安全通信中选择“编辑”

3、选择“要求安全通信(SSL)”后点击“确定”。

2012111916473690962.png

二、创建一个HttpRedirect.htm 文件保存到“C:\InetPub

HttpRedirect.htm中的代码:
<!-- beginning of HttpRedirect.htm file -->
<script type="text/javascript">
function redirectToHttPS()
{
var httpURL = window.location.hostname + window.location.pathname;
var httpsURL = "https://" + httpURL ;
window.location = httpsURL ;
}
redirectToHttps();
</script>
<!-- end of HttpRedirect.htm file -->

三、用HttpRedirect.htm文件替换403文件(见图三)

1、打开你的网站右击选择“属性”

2、选择“自定义错误”点击编辑

3、在“文件”中添加HttpRedirect.htm文件(路径为:C:\Inetpub\HttpRedirect.htm)

2012111916473735404.png

四、测试

输入的网址:http://会自动跳转到https://