tl;dr: How do I do the following in a .conf or .htaccess file:
<IfApache22> # Do A </IfApache22> <IfApache24> # Do B </IfApache24>
Longer question:
With Apache 2.4 the old Order get's deprecated in favor of Require.
In my .htaccess files I have
<FilesMatch "\.(long|list|file|types)$"> Order allow,deny </FilesMatch>
which means Apache fails to start unless I enable access_compat. While doing so presents a useful workaround, I want a solution that works with both syntaxes as the config will be distributed to a lot of servers. The question is how I can detect the current version of Apache and apply the correct directive.
I intend to use the file for a framework that is distributed to and used by a lot of people, and I can't control/guarantee that they have or lack any particular server setup, which is why I'd like the file to be 2.2/2.4 "agnostic".
A hack that I have used.
# Apache 2.2 <IfModule !mod_authz_core.c> Satisfy Any </IfModule> # Apache 2.4 <IfModule mod_authz_core.c> Require all granted </IfModule>
Assuming you have mod_version installed (many distributions ship it by default) you can do the following:
<IfVersion >= 2.4> # Require ... </IfVersion> <IfVersion < 2.4> # Order ... # Deny ... # Allow ... </IfVersion>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With