我要把 aaa.com bbb.com 重定向成 www.aaa.com www.bbb.com,设定如下
server {
listen 80;
server_name aaa.com bbb.com ccc.com;
return 301 http://www.$server_name$request_uri;
}
server {
listen 80;
server_name www.aaa.com;
}
server {
listen 80;
server_name www.bbb.com;
}
server {
listen 80;
server_name www.ccc.com;
}
但是不管我打 aaa.com bbb.com ccc.com 返回的网址都是 www.aaa.com 该怎么设定才会打 aaa.com 返回 www.aaa.com,打 bbb.com 返回 www.bbb.com
1
gqkkk 2017-05-17 17:32:19 +08:00 1
return 301 http://www.$host$request_uri;
|
2
gqkkk 2017-05-17 17:33:33 +08:00
$host
in this order of precedence: host name from the request line, or host name from the “ Host ” request header field, or the server name matching a request $http_name arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores $server_name name of the server which accepted a request |