nginx版本
nginx version: nginx/1.10.2
已经实现了http://(www).airknow.com 跳转到 https://www.airknow.com,但是无法实现https://airknow.com 跳转到https://www.airknow.com 该怎么修改配置
以下是我配置
server {
listen 80;
server_name airknow.com;
return 301 http://www.airknow.com$request_uri;
}
server {
listen 80;
server_name www.airknow.com;
return 301 https://www.airknow.com$request_uri;
}
server {
listen 443;
server_name www.airknow.com;
ssl on;
#...
}
高洛峰2017-05-16 17:10:48
我尝试过在上面第二个server和第三个server之间新加一个server
server {
listen 443;
server_name airknow.com
return 301 https://www.airknow.com$request_uri;
}
重启后https://airknow.com网站都访问不了。
ringa_lee2017-05-16 17:10:48
跟你一样的问题,找到了答案
server {
listen 443;
server_name airknow.com
return 301 https://www.airknow.com$request_uri;
}
server {
listen 443 default_server ssl;
server_name www.airknow.com;
}
像上面这样,在第三个server的443后面加上default_server ssl,不知道会不会有什么负面影响