Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  cPanel  >  How to Deny Access to .htaccess File using cPanel?
Top Scroll

How to Deny Access to .htaccess File using cPanel?

 3 min

Watch this video for a step by step process on How to Deny Access to .htaccess File using cPanel

The .htaccess files are vital hidden files of your hosting and, we recommend protecting them with .htaccess rules. One way to do so is to deny access to the .htaccess file via cPanel File Manager.

To Deny Access to .htaccess File

1. Log in to your cPanel account.

2. Open File Manager and edit the .htaccess file.

Here’s an article that explains: How To Edit A .htaccess File Through The cPanel File Manager?

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/control panel File Manager, even after you have entered the code to deny access.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.