title: Set header on a specific page with .htaccess
body: <p>Trying to use <code>.htaccess</code> to set a header when on a specific page of the website.</p>
  <p>I've tried various methods to set the header, but none of them result in the header being set in the response.</p>
  <p><strong>Method 1:</strong></p>
  <pre><code>SetEnvIf Request_URI ^\/glossary\/$ glossary
  Header Set Test-Header &quot;success&quot; env=glossary
  </code></pre>
  <p>I've also tried a simpler version where I try to match 'glossary' in any part of Request_URI</p>
  <pre><code>SetEnvIf Request_URI glossary glossary
  Header Set Test-Header &quot;success&quot; env=glossary
  </code></pre>
  <p><strong>Method 2:</strong></p>
  <pre><code>&lt;If &quot;%{REQUEST_URI} == '/glossary/'&quot;&gt;
      Header Set Test-Header &quot;success&quot;
  &lt;/If&gt;
  </code></pre>
  <p><strong>Method 3:</strong></p>
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_URI} ^\/glossary\/
  RewriteRule ^ - [ENV=GLOSSARY]
  Header Set Test-Header &quot;success&quot; env=GLOSSARY
  </code></pre>
  <hr />
  <p>I've also output Request_URI in a header in order to confirm that Request_URI has a value:</p>
  <pre><code>Header set Test-Output-Request_URI &quot;%{Request_URI}e&quot;
  </code></pre>
  <p>This results in the Header being set, as expected:</p>
  <pre><code>Test-Output-Request_URI: /glossary/
  </code></pre>
  <p>I'm not much of an expert in .htaccess, nor regex, but normally I'm able to plug away and find a solution. Not this time though. From what I've read, it seems like all of these methods should work, but I'm obviously missing something.</p>
  <p>This is Apache 2.4.35</p>
  <p>Not sure if it makes a difference, but this is a WordPress site.</p>