How to protect .htaccess file?

How to protect .htaccess file?

For security reasons, we recommend that you prevent unauthorized access to your .htaccess file.


To do this, you need to understand how to find this file.


You can edit the .htaccess file using an FTP client or using cPanel.



Add security code to .htaccess file


Step 1:


Log in to your cPanel account and open “File Manager” in the Files section.





You must have made the correct settings to show hidden files.


Because the .htaccess file is a hidden file with a dot prefix; It means you can see it if you haven't turned it on to be visible.


Step 2:


You should look for ".htaccess" in the public_html directory.




Right click to edit the file and click Edit.


Step 3


Add this code:



  1. # .htaccess protection

  2. order allow,deny

  3. deny from all

  4. satisfy all



Click the "Save Changes" button displayed in the upper right corner.


This code will restrict unauthorized access to your .htaccess file.

    • Related Articles

    • File Transfer via FTP

      1. Obtain FTP Access Credentials Host: usually the address of your server or something like ftp.yoursite.com. User: provided by your hosting provider. Password: set by you or provided by the provider. Port: usually port 21 for FTP. 2. Choose an FTP ...
    • How to create a file in File Manager

      1. Log into your cPanel account. 2. In the "Files" section, click on the "File Manger" Icon.  3. Navigate to directory path you want and click on the "File" Icon. 4. In the "New Filename Field" enter your filename like "MyFile.txt" (without the ...
    • How to use File Manager and upload a file

      If you don't want to use a 3rd party FTP Software, you can use the cPanel's inbuilt File Manager.       1. Log into your cPanel account.       2. In the "Files" section, click on the "File Manger" Icon.                3. Once in File Manager ...
    • How to edit a file in FIle Manager

      1. Log into your cPanel account. 2. In the "Files" section, click on "File Manger" Icon.   3. Navigate to the directory where your file is located and right click on the file and then click on "Edit"" in the Context Menu.  4. If the small "Code ...
    • How to protect a folder with username and password

      You can password lock a directory using cPanel's "Directory Privacy" option. 1. Log in to your cPanel account, see how to access cPanel at: https://help.scriptcase.net/portal/en/kb/articles/first-steps-with-the-hosting-access 2. In the "Files" ...