1、编辑配置文件
vim /usr/local/nginx/conf/vhosts/test.conf
2、修改以下内容
server_name www.test.com
为
server_name www.test.com www.aaa.com www.bbb.com;
if ($host != 'www.test.com')
{
rewrite ^/(.*)$ http://www.test.com/$1 permanent;
}
3、重新加载配置文件
/usr/local/nginx/sbin/nginx -s reload
4、使用curl测试访问结果
curl -x127.0.0.1:80 www.bbb.com/1111111 -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.3
Date: Mon, 30 May 2016 06:48:14 GMT
Content-Type: text/html
Content-Length: 184
Connection: keep-alive
Location: http://
转载于:https://blog.51cto.com/riverxyz/1784452