问题描述
location ~ ^/pages/d+_index.json{ proxy_pass /pages/index.json;}
试了一下不行我对nginx配置不太熟悉,请教了.
问题解答
回答1:你可以使用 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; }回答2:
我找到了两种解决的方法rewrite:
location ~ ^/pages/{ rewrite ^/pages/(d+)/d+_index.json http://$host/pages/$1/index.json break;}
proxy_pass
location ~ ^/pages/(d+)/d+_index.json$ { proxy_pass http://$host/pages/$1/index.json;}