Nginx 实现域名跳转

  • 目标:当访问 a 域名的目录 abc 时,跳转到 b 域名的目录 abc, nginx 新增一条 server 配置实现:
1
2
3
4
5
6
7
server  {
listen 80;
server www.a.com;
location /abc/ {
rewrite .+ http://www.b.com/$request_uri permanent;
}
}
1
2
3
注:其中 $request_uri 表示请求参数的原始URI
例如假设访问链接为:http://www.mysite.com:80/test1/test2/test3.html,
$request_uri 表示 /test1/test2/test3.html

Nginx 实现域名跳转
https://ccw1078.github.io/2019/03/01/Nginx 实现域名跳转/
作者
ccw
发布于
2019年3月1日
许可协议