nginx跳转到https重定向的两种方式
启用了https证书访问,都是443的ssl端口,如果默认的80端口,需要跳转重定向到安全连接
方式一:301永久重定向
server {
listen 80;
server_name *.xxxxxxxxxxx.com;
if ($host ~* "^(admin|wx)\..*$") {
return 301 https://$1.xxxxxxxxxxx.com$request_uri;
}
}
方式二:重写
server {
listen 80;
server_name a..xxxxxxxxxxx.com b.xxxxxxxxxxx.com;
rewrite ^/(.*)$ https://www.xxxxxxxxxxx.com/ last;
}