Access Control via Hybrid .htaccess for Both Apache HTTPd 2.2 and 2.4
Hi!
If you're running the Apache HTTPd in the versions 2.2 and 2.4 in different environments but would like to control access to certain directories (include, lib, ...) via Apache, chances are that you don't want to use one 2.2 specific file and a different one for 2.4, especially if you keep transferring and synchronizing the files between those different setups.
Between versions 2.2 and 2.4 a couple of things have changed. The perhaps most prominent change would be the one that comes with the new mod_authz_host module and deals with authorization / access control. Instead of using Order, Allow, Deny and/or Satisfy you are now advised to use the new Require directive.
So what do you do if you cannot switch every .htaccess over to the new format for reasons like the one mentioned in the beginning?
You could in fact enable the mod_access_compat module and keep rolling with the old configuration. But that would only mean procrastinating until you would finally have to deal with it anyway.
The better solution is to use configurations that are not even necessarily dependent on your Apache version (remember, you could just load the legacy compatibility module in 2.4), but in fact check for the correct module to work with. The key element to work with here is the IfModule directive.
# Apache 2.4 <IfModule mod_authz_core.c> Require all denied </IfModule> # Apache 2.2 <IfModule !mod_authz_core.c> Order Allow,Deny Deny from all </IfModule>
As you can see, there are two checks that basically work as an "if ... else" selection. The rest should be self-explanatory.
For more information about the new way of handling access with the Apache HTTPd 2.4, please refer to the official documentation.
I hope this was of any help to you.
Thanks for reading.
Calendar
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Recent Posts
- Windows Defender Firewall Inbound Rule for ICMPv6
- (Re)Setting Hyper-V Virtual Machine Client Zoom Level
- Uploading a Snapshot to a Fresh Home Assistant OS Instance
- Fix GNOME GUI Login After Upgrade to Debian 10 Buster (VirtualBox VM)
- Missing Credentials in Dropdown for Jenkins Build Configuration
Top Posts & Pages
- Fixing Low Stereo Out Sound Volume For the Yamaha MG12XU / MG16XU / MG20XU Audio Mixer
- Making Traceroutes Work with a Firewall (Windows)
- Rewrite MySQL / MariaDB Database Dump Create View Statements For Current User
Subscribe to Blog via E-mail
Categories
Archives
- May 2022
- April 2022
- May 2020
- July 2019
- June 2019
- October 2018
- May 2018
- January 2018
- December 2017
- October 2017
- September 2017
- August 2017
- March 2017
- February 2017
- January 2017
- December 2016
- June 2015
- November 2014
- December 2013
- July 2013
- May 2012
- April 2012
- March 2012
- January 2012
- June 2011
- May 2011
- June 2010
- April 2010
- January 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009