Nginx环境强制http 301跳转https的方法

说明:现在越来越多的人开始为网站启用ssl证书了,安装了ssl后我们都需要让http强制跳转https,并确定网站唯一性,这里介绍了几种方法。

方法

提示:以军哥的lnmp一键安装包为例,Nginx配置文件修改地址为/usr/local/nginx/conf/vhost/xx.com.conf
Nginx环境强制http 301跳转https的方法
方法一:

if ($scheme = http ) {
return 301 https://$host$request_uri;
}

方法二:

server_name southcat.net ;
rewrite ^(.*) https://southcat.net$1 permanent;

方法三:

if ($server_port = 80 ) {
return 301 https://$host$request_uri;
}

方法四:

server_name southcat.net ;
return 301 https://$server_name$request_uri;



给TA打赏
共{{data.count}}人
人已打赏
cj

Linux下,使用speedtest测试网络的上/下行速率

2020-3-2 0:38:14

cj

MinerGate:在Windows、Mac、Ubuntu、安卓手机上挖矿教程

2020-3-2 13:50:28

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