问题
I'm trying to achieve a conditional proxypass directive, so when a certain query string is being called to the virtualhost it proxies it somewhere else and adds Header.
However ProxyPass is not allowed within the if directive.
I was trying this:
VirtualHost <*:443>
ServerName "${APACHE_HOSTNAME}"
<If "%{QUERY_STRING} =~ /some_string/">
RequestHeader set "some_string" "some_string"
Header set "some_string" "some_string"
ProxyPass / https://<domain>/
ProxyPassReverse / https://<domain>/
</If>
</VirtualHost>
Is there any other way arround of this ? Some Virtualhost logic or using re-writes ?
Thanks !
回答1:
ok this worked for me:
<Location "/path_uri">
RewriteEngine on
RewriteCond %{QUERY_STRING} ^<query_string> [NC]
RequestHeader set "header" "header"
RewriteRule ^/(.*) https://URL/ [QSA,P,L]
ProxyPassReverse https://URL/
</Location>
来源:https://stackoverflow.com/questions/50874367/conditional-proxypass-apache