How to Add Password Protection for a Directory Using cPanel

At times, you may find it best practice to password protect a folder on your account. This can add an extra layer of protection to files you do not want the general public to have access to. Password protecting a directory can be easily accomplished using the option within cPanel. In this guide, you can learn how to add and remove password protection on a directory, using cPanel.

How Does Password Protection Work?

It is important to understand how password protection on a folder works. When you choose to password protect a directory in cPanel, cPanel creates a rule in your .htaccess file. This rule specifies that the folder is protected and the visitor will need to provide the proper username and password to log in and view the files within it.

Don’t have time to read our full article? Watch our walk-through video.

Add Password Protection

  1. Log into cPanel.
  2. Go to the Files section and click on the Directory Privacy icon.
    cPanel Files section displayed with Directory Privacy icon highlighted
  3. Select the directory you want to password protect and then you will see the Set permissions for “/home/exampl3/directory/” screen appear.
    Set permissions for directory screen displaying directory listing with public_html directory highlighted as selection.
  4. Click on the checkbox labeled “Password protect this directory:“.
  5. Type a name for the folder you are trying to protect in the field labeled “Enter a name for the protected directory:“.
    Security Settings displayed with checkbox and name fields highlighted and filled in.
  6. Click the Save button to save the name you have entered for the directory and option to password protect the directory.
    Security Settings displayed with Save button highlighted.
  7. Create a user to grant access to the protected directory by typing the credentials into the Username, New Password and Confirm Password fields.
  8. Click Save in order to save the credentials that you have entered.

    Create User section displayed with Save button highlighted.

Remove Password Protection

The steps to remove password protection on a directory are fairly quick and simple. One reason you might want to password protect a directory and then remove the protection is for testing purposes. Or, if you are finally ready to make the folder open to the public, then you can remove the password protection so that everyone can access the files in the directory. The instructions below are the steps for removing the password protection.

  1. Log into your cPanel.
  2. Scroll down to the Files section in your cPanel and then click the Directory Privacy icon.
  3. Select the directory from the list of folders that you want to remove password protection for. The directory should appear with a lock in front of it if it is currently password protected.
  4. Uncheck the box that says “Password protect this directory“.
  5. Finally, click the Save button.

If you have further questions or need further assistance please feel free to contact our Live Technical Support.

Share this Article