How to Password Protect a Directory in cPanel

Website security is important in ensuring cPanel’s account files, directories, databases and hosting configurations are protected at all times. One of the several measures that website owners use to secure their hosting environment is to password protect specific directories using the “Password Protect Directories” feature. This cPanel feature enables you to set up username and password authentication for specific directories on your website. When a website visitor attempts to view the directory or folder through the browser, the cPanel system will prompt them to enter the username and password.

How Does Password Protection Work?

When you password protect a directory in cPanel, the cPanel system creates a rule in .htaccess file. The modified .htaccess rule specifies that any visitor who attempts to access the protected directory and sub folders or files under it must provide a valid username and password in order to access  the files within it.

Steps on How to Add Password Protection on a Directory in cPanel

  1. Login to cPanel as shown below.cpanel login
  2. In the cPanel dashboard, locate the Files section and click on the Directory Privacy as shown in the screenshot below.directory privacy in cPanel
  3. The “Directory Privacy” page will load and you’ll be able to see a list of all directories on your website. Click the Edit button next to the directory or folder you want to protect.password protect a folder in cPanel
  4. You will be redirected to a page where you will provide the security settings for the directory you want to protect. Click the checkbox next to Password protect this directory and also provide the name of the protected directory.  When a user attempts to access the protected directory from a browser, the name you enter in the Security Settings will be displayed. Click the Save button to continue. directory privacy settings in cPanel
  5. You will be required to create at least one user to access the directory. In order to perform this task, you need to go back to the Directory Privacy page by clicking the Go Back button. A create user section will be displayed at the lower section of the page. create user - directory privacy
  6. Enter your desired username and password twice and click the Save button.
  7. To create additional users that will be allowed to access the protected folders, repeat step 5 and 6 above.

How to Remove Password Protection on a Directory in Cpanel

You may want to remove password protection on a folder for a variety of reasons including being ready to allow the general public to access the director and all files within it. The steps of removing password protection on a folder are given below:

  1. Login in to cPanel
  2. Locate the Files section and click on the Directory Privacy icon.
  3. Choose the directory you want to remove the password protection from the list of the website directories that will be displayed. The directory should have a lock symbol infront of it.
  4. Uncheck the box next to the “Password protect this directory“.
  5. Click the Save button to remove the password protection on the folder.

In case you have any additional queries on how to manage your directories and files, you can contact our customer support team through email, live chat or call us. Click here to learn more about our cPanel web hosting service.

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on email
Scroll to Top