通过在HTML中添加一段JavaScript代码,使得http强制跳转https
方法很简单,直接在你的HTML文件或模板文件,例如:footer或header文件中,在<head>标签中加入里插入使用JavaScript代码,即可使其强制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>