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


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

把下面代码保存到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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM