Password-protecting a directory
How to lock a folder in cPanel so only a person with a username and password can open it.
Password protection of a folder is useful for temporary sites, test versions or documents you do not want to publish. When opening the address, the browser asks for a username and password.
- In cPanel, in the Files section, open Directory Privacy.
- Choose the folder: click public_html or the name of the folder you want, then Edit next to the folder you are protecting.
- Tick Password protect this directory.
- Enter a protection name in Enter a name for the protected directory (shown in the login window), e.g. "Private".
- Click Save.
- In Create User enter a username and password (or Generate), then click Save.
After that, every address inside that folder requires a login. Test it in a private browser window.
Removing protection#
Open Directory Privacy again, choose the folder and untick Password protect this directory. Then click Save.
How it works#
cPanel creates or changes the .htaccess file in the folder (and saves passwords in a .htpasswd file outside the public folder). Do not delete those rules manually if protection should stay. See .htaccess basics.
War dieser Artikel hilfreich?
Danke für Ihr Feedback! Brauchen Sie Hilfe? Eröffnen Sie ein Ticket.
