设置nginx反向代理与重写适用于网站中的所有链接

我有以下的Nginxconfiguration:

server { listen 80; location /test { rewrite /test(.*) /$1 break; proxy_pass "http://www.example.com/"; } } 

这适用于主页,当input“ http:// localhost / test ”时,我得到http://www.example.com/的内容,URL仍然是“ http:// localhost / test ”。

很酷,但是当我点击网站中的一个链接时,说/more_examples我想链接被改写为: http:// localhost / test / more_examples 。 在实践中,我得到以下: http:// localhost / more_examples ,这显然不会工作。 这甚至有可能吗?

任何帮助将不胜感激。