带有条件请求头的Apache2配置

带有条件请求头的Apache2配置,apache,apache2,Apache,Apache2,假设我有一个带2 ProxyPass指令的反向代理配置: ProxyPass /webhook1 http://localhost:8080 ProxyPassReverse /webhook1 http://localhost:8080 ProxyPass / http://localhost:8077 ProxyPassReverse / http://localhost:8077 现在,我要设置此标题: RequestHeader set X-Forwarded-Prefix /we

假设我有一个带2 ProxyPass指令的反向代理配置:

ProxyPass /webhook1  http://localhost:8080
ProxyPassReverse /webhook1 http://localhost:8080
ProxyPass /  http://localhost:8077
ProxyPassReverse / http://localhost:8077
现在,我要设置此标题:

RequestHeader set X-Forwarded-Prefix /webhook1/

只有在匹配了/webhook1的情况下,而不是在一般情况下,您才能向我展示实现这一点的最简单的配置?

我不熟悉Apache配置语法,但我刚刚找到了我想要的内容,因此下面是经过测试的答案:

SetEnvIf Request_URI ^/webhook1.* WEBHOOK1

ProxyPass /webhook1  http://localhost:8080
ProxyPassReverse /webhook1 http://localhost:8080
ProxyPass /  http://localhost:8077
ProxyPassReverse / http://localhost:8077

RequestHeader set X-Forwarded-Prefix /webhook1/ env=WEBHOOK1