Nginx以及单页面http自动跳转https方法

在配置80端口的文件里面,写入以下内容即可。

server {
listen 80;
server_name localhost;
rewrite ^(.*)$ https://$host$1 permanent;

location / {
root html;
index index.html index.htm;
}

单页面中配置http自动跳转https方法
在需要强制为https的页面上加入该代码进行处理
<script type=”text/javascript”>
var url = window.location.href;
if (url.indexOf(“https”) < 0) {
url = url.replace(“http:”, “https:”);
window.location.replace(url);
}
</script>

給TA打賞
共{{data.count}}人
人已打賞
服務器運維

apache如何设置http自动跳转到https

2016-10-28 6:32:03

服務器運維

nginx https配置方法:http和https共存

2016-10-28 6:33:25

0 Reply AAuthor MManager
    暫無討論,說說你的看法吧
搜索