http模式访问301重定向到https模式

网站强制访问https模式,以wordpress为例,将以下的跳转代码添加到当前网站所有使用的伪静态规则conf文件中,即可实现所有的http访问都跳转到https访问,并且是继承目录的,具体实现方法就是把http模式访问301重定向到https模式。

 

if ($server_port = 80) {

return 301 https://$server_name$request_uri;

}

if ($scheme = http) {

return 301 https://$server_name$request_uri;

}

error_page 497 https://$server_name$request_uri;

保存后,输入 /etc/init.d/nginx restart , 重启nginix。就ok了!

给TA打赏
共{{data.count}}人
人已打赏
原创跟我一起做

如何去除 CNZZ站长统计的图标

2016-6-13 20:02:06

跟我一起做

自定义QQ消息小尾巴

2016-6-15 22:36:37

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索