http强制跳转到https.jpg

安装ssl证书并开启https访问之后,为了url统一化,最好将http网址强制跳转到https地址。

nginx服务器的操作方法为在nginx.conf中添加以下代码:

rewrite ^(.*)$ https://$host$1 permanent;

添加后:

server
    {
        listen 80;
        #listen [::]:80;
        server_name xxx.com www.xxx.com;
        .......
	rewrite ^(.*)$ https://$host$1 permanent;
        .......
    }