%{DOCUMENT_ROOT} variable inside If statement in Apache 2.4
<p><br>
in Apache 2.4.6 (the up-to-date version from CentOS 7 repository) I am trying to pass all the PHP files for processing to a specially compiled PHP-FPM in case that "php7.enable" file is present in the root of the website. </p>

<p>If I try this:</p>

<pre><code>&lt;If "-f %{DOCUMENT_ROOT} . '/php7.enable'"&gt;
 RewriteEngine On
 RewriteRule "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000/%{DOCUMENT_ROOT}/$1" [P]
&lt;/If&gt;
</code></pre>

<p>the condition works, but the %{DOCUMENT_ROOT} on the RewriteRule line is not expanded to the variable value, but is everytime empty. Strange is, that outside the "If" block, the expansion works. 
Does anybody have any idea why and how to make it work ?
Thanks.</p>