# http強制跳轉(zhuǎn)https
server
{
listen 80;
server_name www.lzskyline.com lzskyline.com;
# request_uri 取原始請求地址, uri 處理后的請求地址(不帶參數(shù)伦糯、URL解碼)
return 301 https://www.lzskyline.com$request_uri;
}
# 域名不帶www強制跳到帶www
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.lzskyline.com lzskyline.com;
# 也可以新增一個server監(jiān)聽443, 綁定域名lzskyline, 用return 301的方式跳轉(zhuǎn)到這里
if ($http_host !~ "^www.lzskyline.com") {
# permanent = 301 永久跳, redirect = 302 臨時跳(spam風(fēng)險)
rewrite /.* https://www.lzskyline.com$request_uri permanent;
}
}
博客文章遷移: 2019-10-13 18:38