网站安装ssl证书后,但是只想前端使用https,后台保持http如何实现呢?正常在服务器配置文件里修改会强制全站https,那我们可以直接在前端页面中用js来强制跳转https,这样后台就可以继续保持http访问了。
具体的实现js代码如下:
<script type="text/javascript">
var sslsite ="https:";
if(window.location.protocol != sslsite){
window.location.href = sslsite + window.location.href.substring(window.location.protocol.length);
}
</script>
把以上js代码放到网站<head>标签中就可以实现前端强制跳转https协议访问了。(外观-主题编辑器-主题文件-首页模板(index.php)