用rewrite把旧域名直接跳转到新域名的nginx配置

来自:互联网
时间:2020-09-19
阅读:

把下面代码保存到daziran.com.conf 放在Nginx配置目录下 /etc/nginx/conf.d/

#把旧域名zdz8207直接跳转到新域名daziran.com的nginx配置
server {
    listen       80;
    server_name  zdz8207.com www.zdz8207.com;
    access_log  /var/log/nginx/access_zdz8207.com.log;
    error_log  /var/log/nginx/error_zdz8207.com.log;
    
    rewrite /.* http://daziran.com$uri permanent;
    
    error_page 404 /404.html;
        location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

测试配置是否正确
# nginx -t
重启nginx
service nginx restart
查看nginx编译进去的模块命令:
nginx -V

返回顶部
顶部