htaccess If...Else always selects Else
<p>I set an environment variable in <strong>httpd-vhosts.conf</strong></p>

<pre><code>SetEnv EARLY_VAR 1
</code></pre>

<p>I try setting special rules based on its value in <strong>.htaccess</strong></p>

<pre><code>&lt;If "%{ENV:EARLY_VAR} == '1'"&gt;
   SetEnv TEST_VAR  if_branch
&lt;/If&gt;
&lt;Else&gt;
    SetEnv TEST_VAR  else_branch
&lt;/Else&gt;
</code></pre>

<p>I expect <code>TEST_VAR</code> environment var to equal <code>if_branch</code>.  In <strong>PHP</strong></p>

<pre><code>var_dump(getenv('EARLY_VAR')); // string '1'
var_dump(getenv('TEST_VAR')); // string 'else_branch'
</code></pre>

<p>I also tried setting <code>EARLY_VAR</code> in <code>.htaccess</code> above the If/Else, both using <code>SetEnv</code> and <code>SetEnvIf</code>.  Always the <em>Else</em> branch is executed.</p>

<p>Why is this?</p>

<p><code>Apache 2.4</code></p>