Make .git folder inaccessible for all cPanel accounts

The Emperor

Member
May 9, 2018
15
0
1
Greece
cPanel Access Level
Root Administrator
WHM installation has more than 120 accounts from which at least the half have a .git folder into their web folder.

How can I massively make .git folder inaccessible through web for every present and future account so I don't have to put an .htaccess file to each one of it each time ?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,251
313
Houston
Something like the following would work in a VirtualHost Include:

Code:
# do not allow .git version control files to be issued
<Directorymatch "^/.*/\.git+/">
  Order deny,allow
  Deny from all
</Directorymatch>
<Files ~ "^\.git">
    Order allow,deny
    Deny from all
</Files>
Instructions on how to modify the VirtualHosts with includes can be found here: Modify Apache Virtual Hosts with Include Files - EasyApache 4 - cPanel Documentation