Nginx环境下,如何让http跳转到https?
编者按:
在配置文件中查找到serve{··· ····},比如找到下面的代码 server_name abc.com www.abc.com;在其下面添加以下代码:if ($scheme = http ) {return 301 https://$host$request_uri;}在Nginx相关配置文件中查找到serve{··· ····} 区块,然后在该区块中找到下面的示范代码
server_name abc.com www.abc.com;
在其下面添加以下示范代码:
if ($scheme = http ) {
return 301 https://$host$request_uri;
}
保存并重启Nginx,观察http是否正常跳转到https。
