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…

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.

Originally published on WebyStrata.com Blog.

Written By

Shaik Sai Meera

WebyStrata Editorial Team

Shaik Sai Meera shares practical publishing insights, comparisons, and WordPress-focused growth guidance for modern web teams.

351 articles published Member since 2021