How to Set Up Directory Privacy in cPanel

Why Password Protect a Directory?

Directory Privacy is used to password-protect downloads, files, or pages that you only want specific people to access. When you enable this feature, a user that tries to open a protected folder will be prompted to enter a username and password before they can access the content.

How to Password Protect A Directory

Before beginning, you will need access to the cPanel of your hosting account. This can be done through the Client Area or by directly logging into the server. In cPanel, locate Directory Privacy under the FILES section and click to access the configuration screen.

Screenshot_2023-02-03_at_1.40.37_PM.png

You will now see a full list of all of your website’s directories. You can click on a directory to access its subdirectories, which can also be password protected. To the right of each directory, you will notice an EDIT button. Click on this button for the directory you wish to password protect. In the example below we're going to add password protection to the public_html directory. The No indicates that the directory is not yet protected.

Screen_Shot_2022-01-17_at_2.44.52_PM.png

After clicking EDIT you will be taken to a screen where the initial permissions for the folder you wish to password protect can be configured. Click Password protect this directory which will unlock the text box below it and enter a name for the protected directory. This does not have to be the actual name of the directory. It will automatically add Protected ‘your directory name’ which should suffice unless you have a specific need for a personalized name. Once this has been done, click the Save button.

Screen_Shot_2022-01-17_at_2.58.51_PM.png

You'll receive a message stating that the system has set the access permissions for the directory. Click the Go Back link below it.

The second part of the process is to create a new user that can access the directory.

Screen_Shot_2022-01-17_at_3.10.14_PM.png

Once you have filled in the necessary information, click the Save button. You will once again see the success message, indicating that your directory is password protected. Now when anyone accesses the directory, a Sign in dialog will appear asking for the username and password.

Sign_in.png

What’s Happening Behind the Scenes

cPanel creates two files when it password protects a directory. An “.htaccess” file is put in the directory being protected. You also get a “passwd” file outside of the publicly viewable structure of your website. This is in the .htpasswds directory above your home directory.

Was this article helpful?
0 out of 0 found this helpful

Articles in this section

See more
Reclaim Hosting Support Hours
8:00 am - 5:00 pm ET, Monday through Friday
Submit a Ticket
Get a quick and helpful response from the pros.
Need Extra Support?
No problem, we're here to help! Talk to us about Professional Services or custom Service Level Agreements.