I have Apache 2.4 and tried to redirect dotfolders/dotfiles to 404, but it didn't work. I have cpanel and need to do this setting globally not in .htaccess.
I added:
RedirectMatch 404 /\\..*(/.*|$)
<Files ~ "^\.">
Order allow,deny
Deny from all
Satisfy All
to pre_main_2.conf and restarted Apache, but it didn't work
Please help
Thank you.