SOLVED AllowOveride None to Home Directories

ItsMattSon

Well-Known Member
Sep 5, 2016
182
38
103
Perth
cPanel Access Level
Root Administrator
Hi guys,

As I understand it, this directive below (in httpd.conf) allows .htaccess in root directory and below - so everywhere?

<Directory "/">
AllowOverride All
Options FollowSymLinks Indexes SymLinksIfOwnerMatch
</Directory>

That was already like that so I presume it's a default but I'd like to disable .htaccess for users unless explicitly allowed.

To do it, I believe I need to make a new directory block with "/home/user" and set AllowOverride to None. But where? :p

The Documentation for Advanced Apache Configuration has been quite helpful, so if I put it in httpd.conf and distiller the file it could work, right? But *should* it instead go in one of the Include Editor field in WHM? And if so, which one is the appropriate one?

Apologise for the beginner question. I sift through a fair few related threads before I hassle you guys with another one.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

You can take the the following steps modify the entry:

1. Copy the Apache 2.4 template for EasyApache 4 to allow for customization:

Code:
cp -a /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local
2. Edit /var/cpanel/templates/apache2_4/ea4_main.local to change the AllowOverride entry to none:

Code:
vi /var/cpanel/templates/apache2_4/ea4_main.local
3. Save the changes, and then run:

Code:
/scripts/rebuildhttpdconf
Let us know if this helps.

Thank you.
 

ItsMattSon

Well-Known Member
Sep 5, 2016
182
38
103
Perth
cPanel Access Level
Root Administrator
Hi @cPanelMichael,

The solution looked promising, but upon editing ea4_main.local and rebuilding httpd conf (definitely has changed in /usr/local/apache/conf/httpd.conf), I can still use .htaccess files in my user accounts. Shouldn't the below have disabled that?

<Directory "/">
AllowOverride None
Options FollowSymLinks Indexes SymLinksIfOwnerMatch
</Directory>
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

Could you let us know the specific entries in your .htaccess files that are still working? Are you attempting to disable .htaccess usage completely? If so, you'd have to add an additional line under "AllowOverride None" for "AllowOverrideList". For example:

Code:
AllowOverrideList Redirect RedirectMatch
The Apache documentation explains how this works at:

core - Apache HTTP Server Version 2.4

Thanks!
 

ItsMattSon

Well-Known Member
Sep 5, 2016
182
38
103
Perth
cPanel Access Level
Root Administrator
Hi Michael,

I just set "Options Includes" in .htaccess in /home/user/public_html and put an local_date SSI in my index and it showed up. Without it in htaccess though, it's disabled by default thanks to your help in another thread (unticked it in the WHM's Apache Configuration).

I thought that AllowOverride None would prevent any overrides?

Theoretically, I shouldn't have to completely disable .htaccess with AllowOverrideList, should I?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Please post the output from:

Code:
grep AllowOverride /var/cpanel/templates/apache2_4/*
grep AllowOverride /usr/local/apache/conf/includes/*
Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Could you open a support ticket using the link in my signature so we can take a closer look and determine why it's not working? You can post the ticket number here and I'll update this thread with the outcome.

Thank you.
 

ItsMattSon

Well-Known Member
Sep 5, 2016
182
38
103
Perth
cPanel Access Level
Root Administrator
Hi @cPanelMichael,

All sorted!

I believe there must have been some failure in the rebuilding of the conf file (maybe on my part, not sure). The good news is that I can't seem to replicate the error anymore as of today (I hadn't actually tried since 11th Nov when I first posted the odd behavior in this thread).

I can only assume that it was fixed when the upcp cron ran between then and now (which it does every night).

Thanks very much for the help as always!
 
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

I'm happy to see the issue is now resolved. It's working as intended on a test system as well, but feel free to let us know if you encounter any additional issues related to this topic.

Thanks!
 
  • Like
Reactions: ItsMattSon