更改test.com.conf
server
{
listen 80;
server_name test.comtest1.comtest2.com;
index index.html index.htm index.php;
root /data/wwwroot/test.com;
if ($host != ‘test.com‘ ) {
rewrite ^/(.*)$ http://test.com/$1 permanent; #如果访问的不是test.com,则跳转到这边,permanent代表301
}
}
? server_name后面支持写多个域名,这里要和httpd的做一个对比
? permanent为Linux- Nginx域名重定向
原文:http://blog.51cto.com/13451715/2322350