ifVersion - does not work in .htaccess

amstel

Active Member
Nov 18, 2015
25
3
3
UK
cPanel Access Level
Root Administrator
Hi all,

Problem: mod_version is loaded but a directive IfVersion does not work in my Apache 2.4.39 (cPanel).
Code:
# httpd -M
...
version_module (shared)
...
Despite proper entry in .htaccess , I can still access files in that protected directory.
Code:
<IfVersion < 2.4>
    order allow,deny
    deny from all
</IfVersion>
<IfVersion >= 2.4>
    Require all denied
</IfVersion>
If I change .htaccess to one line:
Require all denied
files are still accessible in that folder.

If I change .htaccess to two lines:
order allow,deny
deny from all

then it works ok.

I have more than 30 htaccess files with the directive IfVersion and I would like to avoid change them manually.
Please could you advise how to fix it?

Code:
/etc/redhat-release:CentOS Linux release 7.6.1810 (Core)
/usr/local/cpanel/version:11.80.0.22
/var/cpanel/envtype:hyper-v
CPANEL=release
 

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
6,762
535
263
Houston
cPanel Access Level
DataCenter Provider
I tested this by installing mod_version through easyapache 4 then adding your IfVersion directives to an .htaccess and found that I was not able to replicate an issue.

One thing I did possibly do differently was run the following:

Code:
/scripts/updateuserdomains
/scripts/updateuserdatacache
mv /etc/apache2/conf/httpd.conf{,.bk}
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd