思路:既然选择 要求SSL 提示403错误,那为什么不在403错误页面加上强制js由http到https勒?
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>
Copyright © 1998 - Gworg, Inc. All Rights Reserved. 江苏光网数字认证有限公司版权所有
苏ICP备15058404号 苏公网安备32058202010008号
