修改(二)的test.com.conf配置文件
server
{
listen 80;
server_name test.com test2.com test3.com; #多添加几个域名
index index.html index.htm index.php;
root /data/wwwroot/test.com;
if ($host != 'test.com' ) {
rewrite ^/(.*)$ http://test.com/$1 permanent;
} #写成全部是 rewrite http://$host/^/(.*)$ http://test.com/$1 permanent;
}