location ~ ^/pages/\d+_index.json{
proxy_pass /pages/index.json;
}
试了一下不行
我对nginx配置不太熟悉,请教了.
PHPz2017-05-16 17:12:33
你可以使用 rewrite 重写你的请求路径
location / {
rewrite ^/pages/\d+_index\.json /pages/index.json break;
proxy_pass http://127.0.0.1:8080;
}
# 测试下 会返回重写后的 url /pages/index.json
location = /pages/index.json {
return 200 $request_uri;
}
阿神2017-05-16 17:12:33
我找到了两种解决的方法
rewrite:
location ~ ^/pages/{
rewrite ^/pages/(\d+)/\d+_index.json http://$host/pages//index.json break;
}
proxy_pass
location ~ ^/pages/(\d+)/\d+_index.json$ {
proxy_pass http://$host/pages//index.json;
}