只需用到参数:rewrite
rewrite ^/(.*) 新域名/$1 permanent;
例如:
老域名是:http:127.0.0.1,新域名是:http://www.baidu.com,则配置如下:
server {
listen 80;
server_name http:127.0.0.1;
rewrite ^/(.*) http://www.baidu.com/$1 permanent;
}server {
listen 443;
server_name https:127.0.0.1;
rewrite ^/(.*) https://www.baidu.com/$1 permanent;
}
运行结果:
地址栏输入:127.0.0.1?id=1&name=ss
结果为:
本地执行以及Nginx本地安装见下一篇博客: