## 编辑配置文件

[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

## 测试

参考: