title: LocationMatch not matching like Location (Apache 2.4)
body: <p>I'm trying to understand what is going on with <code>LocationMatch</code>. Right now I have a <code>Location</code> similar to the following,</p>
  
  <pre><code>&lt;Location "/context"&gt;
    RequestHeader set X-Forwarded-Proto https
    RequestHeader set X-Forwarded-Port 443
    ProxyPreserveHost On
    ProxyPass        http://example.com/context retry=0 connectiontimeout=300 timeout=300
    ProxyPassReverse http://example.com/context
  &lt;/Location&gt;
  </code></pre>
  
  <p>Next I change only <code>Location</code> to <code>LocationMatch</code>, as below, and that works fine.</p>
  
  <pre><code>&lt;LocationMatch "/context"&gt;
    RequestHeader set X-Forwarded-Proto https
    RequestHeader set X-Forwarded-Port 443
    ProxyPreserveHost On
    ProxyPass        http://example.com/context retry=0 connectiontimeout=300 timeout=300
    ProxyPassReverse http://example.com/context
  &lt;/LocationMatch&gt;
  </code></pre>
  
  <p>But as soon as I introduce a regular expression this no longer matches correctly. For example, I want to match paths starting with <code>/context</code>,</p>
  
  <pre><code>&lt;LocationMatch "^/context"&gt;
    RequestHeader set X-Forwarded-Proto https
    RequestHeader set X-Forwarded-Port 443
    ProxyPreserveHost On
    ProxyPass        http://example.com/context retry=0 connectiontimeout=300 timeout=300
    ProxyPassReverse http://example.com/context
  &lt;/LocationMatch&gt;
  </code></pre>
  
  <p>I've been through the <a href="https://httpd.apache.org/docs/2.4/mod/core.html#locationmatch" rel="nofollow noreferrer">documentation</a> multiple times and can't seem to figure out why this regex doesn't match. I've also seen SOQs like <a href="https://stackoverflow.com/questions/51560733/apache-locationmatch-matching-urls-starting-with">Apache LocationMatch matching urls starting with...</a> but this regex doesn't work. I have a single <code>VirtualHost</code> on a vanilla Ubuntu apache2 install with this single <code>LocationMatch</code>. The entire conf file looks like this,</p>
  
  <pre><code>ProxyRequests off
  
  PassEnv HTTPD_SERVER_NAME HTTPD_SERVER_ADMIN SSL_CERTIFICATE_FILE SSL_CERTIFICATE_KEY_FILE
  
  &lt;VirtualHost *:443&gt;
    SSLEngine on
    SSLCertificateFile ${SSL_CERTIFICATE_FILE}
    SSLCertificateKeyFile ${SSL_CERTIFICATE_KEY_FILE}
  
    Protocols h2 http/1.1
    ServerName ${HTTPD_SERVER_NAME}
    ServerAdmin ${HTTPD_SERVER_ADMIN}
    DocumentRoot /var/www/html
  
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
  
    SSLCipherSuite EECDH+AESGCM:EDH+AESGCM
    # Requires Apache 2.4.36 &amp; OpenSSL 1.1.1
    SSLProtocol -all +TLSv1.3 +TLSv1.2
    SSLOpenSSLConfCmd Curves X25519:secp521r1:secp384r1:prime256v1
    # Older versions
    # SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
    SSLHonorCipherOrder On
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
    Header always set X-Frame-Options DENY
    Header always set X-Content-Type-Options nosniff
    # Requires Apache &gt;= 2.4
    SSLCompression off
    # Requires Apache &gt;= 2.4.11
    SSLSessionTickets Off
    SSLProxyEngine on
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
  
    &lt;LocationMatch "^/context"&gt;
      RequestHeader set X-Forwarded-Proto https
      RequestHeader set X-Forwarded-Port 443
      ProxyPreserveHost On
      ProxyPass        http://example.com/context retry=0 connectiontimeout=300 timeout=300
      ProxyPassReverse http://example.com/context
    &lt;/LocationMatch&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>My question is, should <code>&lt;LocationMatch "^/context"&gt;</code> match URLs starting with <code>/context</code>? For example, <code>https://mydomain/context</code>? And if this should match, any idea what else could be interfering? I'm on version 2.4.41, but I've seen this behavior since at least 2.4.6. Thanks</p>