Apache 2.4 config to work with 2.2

apache-2.2apache-2.4

I have upgraded to Apache 2.4 and I needed to change all

Order allow,deny
Allow from all

to

Require all granted

however, that caused those virtual host files to stop working on Apache 2.2.

Is there a way to write some IF in the configuration to get get same virtual host file to work for both versions?

Best Answer

You can use mod_version (link)

<IfVersion >= 2.4>
     Require all granted
</IfVersion>
<IfVersion < 2.4>
     Order allow,deny
     Allow from all
</IfVersion>