title: Apache mod_headers cannot unset header on a path
body: <p>I am trying to set a header using mod_headers in Apache in all cases EXCEPT a certain path. I've tried each of the three variations below to do so, but none of them seem to work properly to exclude the path. In ALL cases I get the header for all requests, including those that match the example path, e.g.: <a href="http://example.com/charts/24_hour_commodity/450/300" rel="nofollow noreferrer">http://example.com/charts/24_hour_commodity/450/300</a></p>
  
  <pre><code>&lt;VirtualHost *:8200&gt;
  ...
      SetEnvIfNoCase Request_URI "^/charts/.*" frameallow
      Header set X-Frame-Options SAMEORIGIN env=!frameallow
  ...
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>&lt;VirtualHost *:8200&gt;
  ...
      Header always set X-Frame-Options SAMEORIGIN
      &lt;LocationMatch "^/charts"&gt;
          Header always unset X-Frame-Options
      &lt;/LocationMatch&gt;
  ...
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>&lt;VirtualHost *:8200&gt;
  ...
      Header always set X-Frame-Options SAMEORIGIN
      &lt;Directory "/full/path/to/charts"&gt;
          Header always unset X-Frame-Options
      &lt;/Directory&gt;
  ...
  &lt;/VirtualHost&gt;
  
  #tried both with and without the 'always' in all configs
  </code></pre>
  
  <p>Can anyone help me figure out why the header is set in the first example or not unset in the following two? Any one working solution would be enough... </p>
  
  <p>UPDATE: 
  After reading about order of processing on the Apache site, I tried using  conditional blocks instead. Neither of those work either:</p>
  
  <pre><code>&lt;If "%{REQUEST_URI} =~ m#^/charts#"&gt;
      Header unset X-Frame-Options
  &lt;/If&gt;
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>SetEnvIfNoCase Request_URI "^/charts" frameallow
  &lt;If "reqenv('frameallow') == 1"&gt;
      Header unset X-Frame-Options
  &lt;/If&gt;
  </code></pre>
  
  <p>So, still broken. Must be something about the Header statements not firing after a certain point in processing. Or the ones int he conditional somehow firing before the main one and being overridden. Cannot find a way to debug it down to the root cause though.</p>