sparek-3

Well-Known Member
Aug 10, 2002
2,152
268
388
cPanel Access Level
Root Administrator
Regarding the new .htaccess Optimization feature, if this is set to DocumentRoot doesn't this interfere with the Optimize Website feature in users cPanels?

The Optimize Website (mod_deflate) adds a .htaccess file into the user's home directory. If AllowOverride is only permitted into individual DocumentRoots, then .htaccess file in the user's home directory will never be read, correct?

Of course, if you use the recommended setting of per home directory, this is not an issue. And that may be the best solution here, just note that if you use per DocumentRoot AllowOverride then you won't be able to use The Optimize Website feature in end-user's cPanels. Otherwise, you would need to revamp the Optimize Website to be enabled per VirtualHost or a flag would have to be set so that subsequent VirtualHosts created under the end-user's account get the appropriate mod_deflate directives set in their .htaccess file.


Would a better solution be to avoid .htaccess files completely? I believe this is what nginx does. Per VirtualHosts directives could be added to /etc/apache2/conf.d/userdata/(std|ssl)/2_4/<user>/<virtualhost> directory structure. The nginx argument is that each web-server request generates more file-system hits as it has to look for .htaccess files every where. I don't know how much of a performance hit this really is, but it makes sense that it would at least take some performance hit.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

That's correct, if you set "Optimize .htaccess (AllowOverride)" to "Search Document Root and Below" in "WHM >> Apache Configuration >> Global Configuration", then the entries added to the "/home/$user/.htaccess" file when enabling the "Optimize Website" feature in cPanel are not detected. It also will prevent PHP inheritance from working, leading to potential issues with MultiPHP functionality. Setting the option to "Search Document Root and Below" is not recommended.

That said, if you decided to configure the option to "Search Document Root and Below", then yes, enabling the mod_deflate entries directly in the virtual host is a suitable workaround:

Modify Apache Virtual Hosts with Include Files - EasyApache 4 - cPanel Documentation

I recommend opening a feature request if you'd like to see the default behavior switched from the .htaccess inclusion to a virtual host inclusion when using the "Optimize Website" option.

Thank you.
 

sparek-3

Well-Known Member
Aug 10, 2002
2,152
268
388
cPanel Access Level
Root Administrator
Well, the rant about Would a better solution be to avoid .htaccess files completely was actually about doing away with the .htaccess behavior altogether - a la nginx.

But yea, the Optimize Website probably needs to be moved into the user's Apache userdata directory structure.
 

cinthisone

Registered
Sep 3, 2016
1
0
1
Boston, MA
cPanel Access Level
Root Administrator
Hello,

That's correct, if you set "Optimize .htaccess (AllowOverride)" to "Search Document Root and Below" in "WHM >> Apache Configuration >> Global Configuration", then the entries added to the "/home/$user/.htaccess" file when enabling the "Optimize Website" feature in cPanel are not detected. It also will prevent PHP inheritance from working, leading to potential issues with MultiPHP functionality. Setting the option to "Search Document Root and Below" is not recommended.

That said, if you decided to configure the option to "Search Document Root and Below", then yes, enabling the mod_deflate entries directly in the virtual host is a suitable workaround:

Modify Apache Virtual Hosts with Include Files - EasyApache 4 - cPanel Documentation

I recommend opening a feature request if you'd like to see the default behavior switched from the .htaccess inclusion to a virtual host inclusion when using the "Optimize Website" option.

Thank you.

Thank you for pointing out where this setting was!

When I updated my server, all my Wordpress sites using temporary URLs had broken permalinks. I always use temporary URLs on my development sites.

Does anyone know how to get tempoary URLs working with Wordpress pretty permalinks with this enabled? I would love to enable it for performance.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463