How to protect a folder with Directory Privacy in cPanel
cPanel Directory Privacy lets you require a username and password before opening a specific folder on your site. It is useful for protecting a staging folder, private downloads, client files, or a section you do not want to publish yet.
This protection applies to the web path for that folder. Before you enable it, confirm that you are not blocking files your public site needs, such as images, CSS, or application assets.
Before you start
- Have access to cPanel for the account where the domain is hosted.
- Identify the exact folder you want to protect, for example
public_html/stagingorpublic_html/clients. - Decide which user will be allowed to enter and save a strong password in a secure password manager.
- Test the change on a specific folder before protecting all of
public_html.
Choose the correct folder
- Log in to cPanel and search for Directory Privacy.
- Open the tool. cPanel will show the folder tree and a table with the columns Current Directory, Private, and Actions.
- Click the folder name or icon to navigate. For example, open
public_htmlif the folder is inside the main site. - When you see the exact folder, click Edit in that same row; this is the button that selects the folder for protection.
- Confirm that the path matches the correct domain or subdomain before saving changes.


If you are unsure about the path, open File Manager in another tab and compare the folder with the URL you want to protect.
Enable folder protection
- Inside the selected folder, select Password protect this directory.
- In Enter a name for the protected directory: enter a visible name for the protected area, such as
Private areaorSite staging. - Click Save and wait for the confirmation Success: The system set the access permissions.
- Check whether cPanel says the protection also applies to subfolders, especially if there is public content inside that path.

The visible name may appear in the browser authentication window. Use printable ASCII characters only; cPanel may reject accents or special characters in this field.
Create the authorized user
- On the same Directory Privacy screen, find Create User.
- Enter the Username that will have access to the folder.
- Enter a strong New Password and repeat it in Confirm Password. You can also use Password Generator if you need a new strong password.
- Check Password Strength and click Save.
- Confirm that cPanel shows Success: The system has successfully set the password for user.

If you need to give access to someone else, create a separate user. That lets you remove one access without changing the password for everyone.
Test access from the browser
- Open a private or incognito browser window.
- Visit the protected folder URL, for example
https://yourdomain.com/staging/. - Confirm that the browser asks for a username and password before showing the content.
- Enter the login you created and check that the folder loads correctly.
- Close the private window and open the URL again to confirm that you were not relying on a previous session.
If the site asks for a password on pages that should be public, you probably protected a folder higher than needed.
Common errors
- The URL does not ask for a password: check that you protected the correct folder and test in a private window to rule out cache or saved credentials.
- The password does not work: confirm the exact username, reset the password from Directory Privacy, and copy it again without extra spaces.
- The public site looks broken: you blocked access to images, CSS, or scripts used by other pages; move those assets or protect a more specific subfolder.
- Someone else can no longer enter: create an individual user for that person or reset only their password, without sharing one generic account.
Recommended reading
Still need help?
If this guide didn’t solve your issue, our team can help you via ticket.