How to password protect a folder in cPanel (Directory Privacy)
Sometimes you want a folder on your website to be private, for example a folder with documents for your team, a test copy of your site, or an admin area. With Directory Privacy in cPanel, the browser asks for a username and password before opening the folder. This guide shows you how to password protect a folder.
1) Open Directory Privacy
In cPanel, go to the Files section and click Directory Privacy (1).
2) Choose the folder
Click the folder name to open it (for example public_html), then click Edit (1) next to the folder you want to protect.
3) Turn on the protection
- Tick Password protect this directory (1).
- Write a name for the protected area (2), for example "Private Documents". It appears in the login window.
- Click Save (3).
4) Create a user who can open it
Go back to the same folder. Under Create User write a Username (1), the New Password (2) and repeat it (3), then click Save (4). Give these details only to the people who need access.
Now open the folder address in the browser (for example https://yourdomain.com/private-docs); a login window appears.
Common problems
- The whole site asks for a password → you protected
public_htmlitself. Remove the tick from it and protect only the sub-folder. - WordPress shows errors after protecting wp-admin → WordPress uses
wp-admin/admin-ajax.phpfor visitors too. Protecting wp-admin needs an extra rule; open a ticket and we will set it correctly. - The password does not work → check the username is exactly the one created for this folder, not your cPanel username.
Frequently asked questions
Is this protection secure?
Yes, when your site uses https, because the password is sent encrypted. Make sure you have SSL.
Can I add more than one user?
Yes, create as many users as you need and delete them when they no longer need access.
Do sub-folders get protected too?
Yes, everything inside the protected folder is protected.



