Apache ProxyPass和RewriteRule[P]在http/https方面的作用不同

Apache ProxyPass和RewriteRule[P]在http/https方面的作用不同,apache,mod-rewrite,mod-proxy,Apache,Mod Rewrite,Mod Proxy,我有一个工作配置,看起来像 ProxyPass /roundcube protocol://127.0.0.1:8080/roundcube ProxyPassReverse /roundcube protocol://127.0.0.1:8080/roundcube 当我去 http://www.example.com/roundcube or https://www.example.com/roundcube 如预期的那样,在127.0.0.1:8080上同时或正确代理服务器 但是,我希

我有一个工作配置,看起来像

ProxyPass /roundcube protocol://127.0.0.1:8080/roundcube
ProxyPassReverse /roundcube protocol://127.0.0.1:8080/roundcube
当我去

http://www.example.com/roundcube
or
https://www.example.com/roundcube
如预期的那样,在127.0.0.1:8080上同时或正确代理服务器

但是,我希望能够更好地控制代理何时发生,因此我希望使用mod_rewrite的[p]选项,而不是上面显示的ProxyPass指令。我尝试了以下方法:

RewriteEngine On
RewriteRule ^/roundcube$ /roundcube/ [R]
RewriteRule ^/roundcube/(.*) protocol://127.0.0.1:8080/roundcube/$1 [P]
ProxyPassReverse /roundcube protocol://127.0.0.1:8080/roundcube
使用该配置,当我转到

http://www.example.com/roundcube
https://www.example.com/roundcube
请求按预期正确代理

但是当我去

http://www.example.com/roundcube
https://www.example.com/roundcube
请求404的


所以我的问题是,为什么mod_rewrite代理在http和https请求方面的工作方式与ProxyPass版本不同?根据我的理解,我上面的两个例子在功能上应该是等价的,但事实似乎并非如此。我错过了什么?我还没有找到任何可以解释这一点的文档。谢谢

虽然可能已经太晚了,但我会发布这个答案,以防有人带着同样的问题来到这个页面

ProxyPass的语法与重写规则的语法不同。在重写规则中,要引用协议,应使用
%{SERVER\u protocol}
,如中所述