vhost下配置文件书写如下
server
{
listen 80;
server_name test.com test2.com test3.com;
index index.html index.php index.htm;
root /data/wwwroot/test.com;
if ($host != 'test.com'){
rewrite ^/(.*)$ http://test.com/$1 permanent;
}
}
server_name 后面支持写多个域名
permanent 为永久重定向 状态码301 如果写redirect则为302