仅当匹配到位置时才需要代理传递剩余的 url
location /blog { proxy_pass http://example.com }
即,如果有人请求/blog/page1/temp.html
,他们就会将代理传递给example.com/blog/page1/temp.html
我想将其更改为 example.com/page1/temp.html
最佳答案
I want to change example.com/blog/page1/temp.html to example.com/page1/temp.html
在代理传递指令中指定 uri(在本例中主机名后面的 /
):
location /blog/ {
proxy_pass http://example.com/;
}
或者像这样使用重写:
location /blog {
rewrite /blog/([^/]+) $1;
proxy_pass http://example.com
}
关于nginx - 如何在匹配后仅 proxy_pass 剩余的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48922208/