在nginx配置文件添加:
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
Nginx跳转自动到带www域名规则配置:
在nginx大server中添加
server{
listen 80;
listen ?443;
server_name ?www.xx.com xx.com;
if ($host != ‘www.xx.com‘) {
rewrite ^/(.*)$https://www.xx.com/$1 permanent;
}
参考文档:http://wenku.it168.com/d_000938140.shtml
nginx http301强制跳转https、域名跳转到带www
原文地址:http://blog.51cto.com/lmy666/2322235