title: How can LocationMatch and ProxyPassMatch be Combined?
body: <p>I am setting up an Apache 2.4.6 server on an internal machine for testing purposes. One of the things that Apache server is supposed to do is act as a reverse-proxy for another server found on localhost:3030.</p>
  
  <p>The server on localhost:3030 expects one out of a few dataset names on its first path level (for now, the set comprises only of the dataset <code>experimental</code>, but some more will be added later on), so I am trying to pass that through from the requested path.</p>
  
  <p>In my vhost, this works:</p>
  
  <pre><code>&lt;Location /experimental/&gt;
      ProxyPass http://localhost:3030/experimental/
      ProxyPassReverse /
  &lt;/Location&gt;
  </code></pre>
  
  <p>For additional datasets, I could copy that and replace <code>experimental</code> with the other dataset names. Obviously, that leads to a lot of code duplication/redundancy, which is both a source of errors and a maintenance horror.</p>
  
  <p>Therefore, I would like to become somewhat more flexible and treat several datasets in a single such block. This should be possible with the <a href="http://httpd.apache.org/docs/current/en/mod/core.html#locationmatch" rel="noreferrer"><code>LocationMatch</code> directive</a>.</p>
  
  <p>As indicated by <a href="https://github.com/elasticsearch/kibana/pull/121" rel="noreferrer">this comment</a> and <a href="http://keita.flagship.cc/2013/06/04/locationmatch-and-proxypass/" rel="noreferrer">this page</a>, I need to replace <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass" rel="noreferrer"><code>ProxyPass</code></a> <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassmatch" rel="noreferrer"><code>ProxyPassMatch</code></a> when using that inside a <code>LocationMatch</code> block. Essentially, the <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass" rel="noreferrer">docs</a> state the same:</p>
  
  <blockquote>
    <p>The same will occur inside a LocationMatch section, however ProxyPass does not interpret the regexp as such, so it is necessary to use ProxyPassMatch in this situation instead.</p>
  </blockquote>
  
  <p>The <a href="http://httpd.apache.org/docs/current/en/mod/core.html#locationmatch" rel="noreferrer"><code>LocationMatch</code> docs</a> explain:</p>
  
  <blockquote>
    <p>From 2.4.8 onwards, named groups and backreferences are captured and written to the environment with the corresponding name prefixed with "MATCH_" and in upper case. This allows elements of URLs to be referenced from within expressions and modules like mod_rewrite. In order to prevent confusion, numbered (unnamed) backreferences are ignored. Use named groups instead.</p>
  </blockquote>
  
  <p>That information is only valid as of Apache 2.4.8, which is presumeably why the following does not work on my 2.4.6 installation:</p>
  
  <pre><code>&lt;LocationMatch /(?&lt;dataset&gt;experimental)/&gt;
      ProxyPassMatch http://localhost:3030/%{env:MATCH_DATASET}/
      ProxyPassReverse /
  &lt;/LocationMatch&gt;
  </code></pre>
  
  <p>On the other hand, <a href="http://keita.flagship.cc/2013/06/04/locationmatch-and-proxypass/" rel="noreferrer">this page</a> and <a href="https://groups.google.com/forum/#!msg/railo/3ai5H31uDos/a6JA5w0WnHQJ" rel="noreferrer">that posting</a> imply that the numerical group index (<code>$1</code>) can be used (as the help text is valid only as of httpd 2.4.8, my <em>suspicion</em> / <em>hope</em> is that the numerical reference works before 2.4.8 (?)</p>
  
  <p>In any case, I have tried this:</p>
  
  <pre><code>&lt;LocationMatch "/(experimental)/"&gt;
      ProxyPassMatch http://localhost:3030/$1/
      ProxyPassReverse /
  &lt;/LocationMatch&gt;
  </code></pre>
  
  <p>yet according to the logs, the internal call invokes <code>http://localhost:3030/$1/</code> instead of <code>http://localhost:3030/experimental/</code> when requesting the <code>experimental</code> path on the vhost URL.</p>
  
  <p>The <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassmatch" rel="noreferrer"><code>ProxyPassMatch</code> docs</a> only say:</p>
  
  <blockquote>
    <p>When used inside a LocationMatch section, the first argument is omitted and the regexp is obtained from the LocationMatch.</p>
  </blockquote>
  
  <p>However, the text does not bother to provide an example for how to combine <code>LocationMatch</code> and <code>ProxyPassMatch</code>. <strong>What am I doing wrong?</strong></p>