server {
listen 9000;
server_name 你的域名;
location /api/b {
alias /data/b;
index b.html b.htm;
}
location /api/abc {
set $URL $scheme://$host$request_uri;
if ($URL ~ "abc"){
rewrite "^(.*)abc(.*)$" $1b$2 permanent;
}
alias /data/a;
index a.html a.htm;
}
}
这里把 abc 替换成了 b ,
原请求路径:http://www.xxx.com:9000/api/abc 替换为了 http://www.xxx.com:9000/api/b