我希望用户能够在浏览器中加载网址,但不会重定向:
http://example.com/abc/{var1}/{var2}/def
我希望example.com apache 2.2服务器接受该请求,并且“不可见”并且没有重定向反向代理它:
http://other.example.com/abc/{var1}/{var2}/def
我花了好几个小时尝试RewriteRule,ProxyPass,ProxyPassMatch和ProxyPassReverse的不同组合,但都无济于事。这是我当前的尝试,它似乎重定向到/ test而不是隐形代理。
RewriteRule ^/abc/([^/\.]+)/([^/\.]+)/def/?$ /test/abc/$1/$2/def [P]
ProxyPass /test http://other.example.com/
ProxyPassReverse /test http://other.example.com/
答案 0 :(得分:0)
[P]标志已具有ProxyPass
的功能。您只需添加ProxyPassReverse
即可。此外,如果您想要代理,则必须使用完整网址作为RewriteRule
的第二个操作数。
RewriteRule ^/abc/([^/\.]+)/([^/\.]+)/def/?$ http://other.example.com/abc/$1/$2/def [P]
ProxyPassReverse / http://other.example.com/