您的位置:首页 > 运维架构 > Nginx

Nginx域名重定向

2018-01-04 10:11 134 查看
配置多个域名权重变了。比如第一个是主域名,其他的跳转到主域名。
if ($host != 'test.com' ) {
rewrite ^/(.*)$ http://test.com/$1 permanent;
}

更改test.com.conf
server
{
listen 80;
server_name test.com test1.com test2.com;
index index.html index.htm index.php;
root /data/wwwroot/test.com;
if ($host != 'test.com' ) {
rewrite ^/(.*)$ http://test.com/$1 permanent;
}
}
server_name后面支持写多个域名,这里要和httpd的做一个对比
permanent为永久重定向,状态码为301,如果写redirect则为302
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  域名重定向