我想了解将所有内容重定向到http://example.com/的正确Nginx配置...即:
需要自动重定向到http://example.com/。我该如何配置?
答案 0 :(得分:2)
您可以这样做:
server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
<your other nginx settings>
}
server {
listen 443;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 443;
server_name example.com;
return 301 http://example.com$request_uri;
}