How to Deny Access to .htaccess File using cPanel?
We advise using.htaccess rules to secure your website hosting’s essential hidden files, the.htaccess files. Using the cPanel File Manager, you may block access to the.htaccess file as one method of doing this.
To Deny Access to .htaccess File
1. Log in to your cPanel account.
2. Open File Manager and edit the .htaccess file.
3. Add this code at the end of the file:
# Deny access to hidden files - files that start with a dot (.) <FilesMatch "^\."> Order allow,deny Deny from all
4. Click Save Changes and Close the file.

If you own a VPS or a dedicated server, you can protect the .htaccess/hidden files on all the sites on it. You have to edit the /home/.htaccess file and enter the code there.
Note: If you are an admin, it is still possible to edit the .htaccess file via FTP/cPanel File Manager, even after you have entered the code to deny access.