This document contains information on how to protect a folder on your website with a username and password using cPanel's Directory Privacy tool.
Directory Privacy allows you to require a username and password for anyone attempting to open a folder on your site from the browser. It is useful for private areas, test versions, or files that only certain people should see.
What is it for?
- Restricting access to a folder, for example
https://yourdomain.com/private. - Hiding a site in development while you finish it.
- Adding an extra layer of security to an administration panel.
The protection applies to the folder and all its subfolders. It only acts when entering via the web: it does not affect FTP, Web Disk, or the File Manager.
Access: log in to cPanel from the client portal → Log in to cPanel, or at https://yourdomain.com/cpanel. Then open Files → Directory Privacy.
Protecting a folder
- Navigate to the folder you want to protect. To enter a folder, click on its icon. Folders with a padlock already have protection configured.
- Next to the folder, click Edit.
- Check Password protect this directory.
- In Enter a name for the protected directory, type text, for example
Private area. It is just a label that appears in the login window, it does not change the folder name. - Click Save and then Go Back.
Important: until you create at least one user, nobody can enter the folder. If you protect public_html, the entire site is protected.
Creating authorized users
- Under Create User, type the username.
- Type the password and confirm it, or use the Password Generator. The meter must remain green.
- Click Save.
To change a user's password, type their name and the new password, and save. To remove their access, select them under Authorized Users and click Delete User.
Removing protection
Open the folder with Edit, uncheck Password protect this directory and click Save.
Recommendations
- Use the site with https://. With
http://, the password travels unencrypted. - In WordPress, if you protect the
wp-adminfolder, some site functions that use it may stop working for visitors. If this happens, remove the protection and use a security plugin. - Create one user per person, so you can remove access for one without affecting the others.
Common issues
- The username and password prompt appears over and over again: the username or password do not match. Save the password again from Create User.
- The browser does not ask for the password again: it remembers it during the session. Close the browser or open a private window to test.
- It won't let me create the user: check that the folder permissions are 755 in the File Manager. If they remain the same, open a ticket.
- Error 500 after protecting the folder: there is a conflicting rule in that folder's configuration. Remove the protection and open a ticket.
- I can view files via FTP without a password: this is expected. Protection only acts on web access.
If the folder does not request a password or does not let you enter with a valid user, open a ticket from the client portal or consult via the site's online chat.
