I have a Problem with dynamic content-replacements. Apache-Substitude don't replace variables matched by LocationMatch or request-vars like %{REQUEST_URI}.
my plan is to proxy a page and replace the base-href-content.
href="/" -> href="/proxy/https/my-app.de/"
a typical request looks like: https://my-proxy.localhost/proxy/https/my-app.de/
i tried many spellings to get access to this variables. i tried Substitute with regex and without LocationMatch. and i searched for alternatives for substitute.
<LocationMatch "/proxy/(?<protocol>https?)/(?<target>.*)">
RequestHeader unset Accept-Encoding
RewriteEngine on
RewriteOptions Inherit
RewriteRule ^ %{env:MATCH_PROTOCOL}://%{env:MATCH_TARGET} [P]
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|<base href=\"/\" />|<base href=\"/proxy/%{env:MATCH_PROTOCOL}/%{env:MATCH_TARGET}/\" debug=\"%{REQUEST_URI} %\{env:PROTOCOL} %{env:TARGET} \$\\PROTOCOL %{HTTP:HOST}\" />|"
</LocationMatch>
the result is, nothing helps
<base href="/proxy/{env:MATCH_PROTOCOL}/%{env:MATCH_TARGET}/" debug="%{REQUEST_URI} %{env:PROTOCOL} %{env:TARGET} $PROTOCOL %{HTTP:HOST}" />