I am trying to build a reverse proxy using Apache.
My goal is to proxy all requests of the form <subdomain>.domain.com/file.html
to www.domain.com/<subdomain>/file.html
.
I somehow need to capture the <subdomain>
of the original URL and use it to construct the target URL.
I assume that I need an Apache directive that can match regular expressions on the whole URL, instead of the part of the url after %{HTTP_HOST}
, since my target URL contains the original URL's subdomain. For this reason I can't use the ProxyPassMatch
directive, since it only matches the part of the URL after %{HTTP_HOST}
.
Another alternative is to use as many VirtualHost
sections as my subdomains. But of course this solution doesn't make sense, since my subdomains will keep increasing.
Any tips on how to tackle this?