How to Deny Access to .htaccess File in cPanel

how-to-deny-access-to-htaccess-file-in-cpanel

Steps to Deny Access to the .htaccess File

1. Log in to Your cPanel Account

Access your cPanel using your hosting username and password.

2. Open File Manager

  • Go to the FILES section.
  • Click on File Manager.
  • Locate your website’s .htaccess file.

Make sure hidden files (dotfiles) are enabled in File Manager settings.

3. Edit the .htaccess File

  • Right-click the .htaccess file.
  • Click Edit.

Add the following 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
</FilesMatch>

deny-access-htaccess-file-cpanel

4. Save Changes

  • Click Save Changes
  • Close the editor

Your hidden files will now be protected from unauthorized public access.

Leave a Reply

Your email address will not be published. Required fields are marked *