How to Password-Protect a Directory in cPanel

Restrict access to a folder on your website by adding password protection through the Directory Privacy tool in cPanel.

· Updated · 723 views

Password protecting a directory adds a login prompt before anyone can view the files inside it. This is useful for staging areas, admin folders, private downloads, or pages you are not ready to publish.

When to Use Directory Privacy

  • Protecting a staging or development folder.
  • Securing an admin or internal tools area.
  • Sharing private files with selected people only.

Enabling Protection

  1. Log in to cPanel.
  2. Open Directory Privacy in the Files section.
  3. Browse to the folder you want to protect and select it.
  4. Tick Password protect this directory.
  5. Give the protected area a name, then click Save.

Creating a User

After protecting the directory, you must add at least one user who can log in:

  1. On the same page, find the Create User section.
  2. Enter a username and a strong password.
  3. Click Save.

You can add more users later, each with their own login.

How Visitors Experience It

When someone visits the protected folder, the browser shows a login box. Only those with a valid username and password can proceed. The protection applies to everything inside that folder, including subfolders.

Important Notes

  • Password protection works at the folder level, not for a single file.
  • It uses your .htaccess and .htpasswd files, which cPanel manages for you.
  • To remove protection, return to Directory Privacy and untick the protection option.

If the login prompt does not appear, confirm you selected the correct folder and that at least one user exists. For help, contact support on WhatsApp at +254 796 358081.

Was this article helpful?

Your feedback helps us improve our documentation.

Still Need Help?

Our support team is available 24/7 to assist you.