## 编辑配置文件

[root@aminglinux vhosts]# cd /usr/local/nginx/conf/vhosts/

[root@aminglinux vhosts]# vim test.conf

  server_name www.test.com www.aaa.com www.bbb.com;  

  if ( $host != 'www.test.com' ) {

       rewrite ^/(.*)$ http://www.test.com/$1 permanent;

}

## 检查语法并重新加载

[root@aminglinux vhosts]# /usr/local/nginx/sbin/nginx -t

[root@aminglinux vhosts]# /usr/local/nginx/sbin/nginx -s reload

## 测试

WEBRESOURCE1ec11fd8c746ccd6bec6556efdc0a

参考:

WEBRESOURCE05cf44f72dbbdb53fc3e92fac8d19