How to Use Directory Privacy in cPanel
Learn how to protect specific folders on your website with a username and password using Directory Privacy in cPanel.
Directory Privacy in cPanel allows you to restrict access to a specific folder on your hosting account. When enabled, visitors must enter a valid username and password before they can open files inside that directory.
This feature is useful if you want to protect private content such as client files, internal documents, test pages, development folders, or any section of your website that should not be publicly accessible.
What Is Directory Privacy in cPanel?
Directory Privacy is a built-in cPanel tool that lets you password-protect selected directories in your hosting account. Once enabled, anyone trying to access that folder through a web browser will be asked to log in first.
This protection applies only to the folder you choose and its contents. Subdirectories inside that folder are typically protected as well.
When Should You Use Directory Privacy?
- To protect private downloads or documents.
- To secure staging or development folders.
- To limit access to internal project files.
- To prevent public visitors from opening confidential content.
- To add an extra layer of access control to selected website sections.
How to Access Directory Privacy in cPanel
- Log in to your Account.
- Open your hosting service details.
- Click Login to cPanel.
- In cPanel, go to the Files section.
- Click Directory Privacy.
How to Enable Directory Privacy
- Inside Directory Privacy, browse the folder list and locate the directory you want to protect.
- Click the folder name to open its privacy settings.
- Tick the checkbox labeled Password protect this directory.
- Enter a name for the protected directory. This label may appear in the login prompt.
- Click Save.
- cPanel will confirm that the directory protection has been enabled successfully.
How to Create a Username and Password
After enabling protection, you must create at least one authorized user who can access the protected folder.
- In the same Directory Privacy page, scroll down to the Create User section.
- Enter a username.
- Enter a strong password, or use the password generator if available.
- Confirm the password.
- Click Save or Create User.
How Directory Privacy Works
Once Directory Privacy is enabled and a user is created, anyone opening the protected folder in a browser will see a login prompt.
Only users who enter the correct username and password will be able to continue and view the contents of the folder.
How to Remove or Disable Directory Privacy
- Return to Directory Privacy in cPanel.
- Open the protected folder settings.
- Untick the checkbox for Password protect this directory.
- Click Save.
- You can also remove existing users if they no longer need access.
Best Practices for Using Directory Privacy
- Protect only folders that need restricted access.
- Use strong passwords and update them regularly.
- Remove unused authorized users.
- Avoid protecting the main public website folder unless necessary.
- Test the protected directory after setup to confirm it works as expected.
Common Issues and Troubleshooting
Login prompt keeps appearing: Make sure you are entering the correct username and password.
Website pages became restricted: Check whether you enabled Directory Privacy on a public folder by mistake.
User cannot access the folder: Confirm that the user was created successfully and the password is correct.
Changes do not seem immediate: Clear your browser cache and test again in a private browsing window.