How to Password Protect a Directory via cPanel

Password protecting directories is useful in cases where you wish to grant specific users access to specific directories while denying any attempts to access such directories for anyone else. In this example, you will see how to password a directory that contains a few documents we want to keep private, but accessible through our website if a user has the correct login credentials.

What you’ll need

Before you begin this guide you’ll need the following:

  • Access to the cPanel of your hosting account
  • A folder you wish to protect

Step 1 — Logging into your cPanel

Login into the cPanel of your hosting account and find the “Directory Privacy” tool. It can also be named “Password protection” or similar.

Directory privacy tool location

Step 2 — Navigating the directory tree

Once inside, use the small cpfolder icon to navigate the directory tree. Click the one next to ‘public_html’ to delve deeper into that folder.

Tree navigation

Step 3 — Selecting the directory to be protected

Once you have found the directory that you want to protect, click on the name of the directory to open cPanel’s Security Manager of that directory. In this example, we will be protecting the archives2016 folder.

Selecting directory to be protected

Step 4 — Enabling password protection

In order to enable password protection for your directory, check the Password protect this directory option and input a label for your directory, i.e. “Archived documents 2016”. Click Save to enable password protection for that directory.

Enabling password protection

Step 5 — Creating a user to access the directory.

IMPORTANT! Our directory is now protected, however, there are no users created that can access it. You must create a user that can access this directory. This must be done on the same page, simply find the Create User section and input the username and password and click Save to create your user. Make sure to use a strong password for your user.

Creating user for directory access

Step 6 — Testing our password protection

All that remains is to try and access our directory. In our example, we will visit We are prompted with a username and password prompt. Let’s input our user credentials that we created in the last step and try to access the directory.

Directory access prompt

Successful login to directory

Success! We successfully logged in with the username and password that we created. If an incorrect username or password is supplied, access to the directory will be denied.


  • To change a user’s password, enter the user’s information again in the Create User section of the interface, but enter a different password for the user and click Save.
  • To remove password protection from the directory, deselect the Password protect this directory checkbox in the Security Settings section of the interface and click Save.


We learned how to password protect directories via cPanel’s Directory Privacy tool. Additional information is available at

About the author

Edvinas B.

Edvinas mentors and trains every new customer support agent at Hostinger. When he's not teaching new guys the secrets of providing an exceptional service, he likes to travel the world and play basketball.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in cPanel
How to Add a Redirect for Your Website