DOCS

Password-protecting a directory

How to lock a folder in cPanel so only a person with a username and password can open it.

Aggiornato 05.10.2026. 2 min di lettura

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.

  1. In cPanel, in the Files section, open Directory Privacy.
  2. Choose the folder: click public_html or the name of the folder you want, then Edit next to the folder you are protecting.
  3. Tick Password protect this directory.
  4. Enter a protection name in Enter a name for the protected directory (shown in the login window), e.g. "Private".
  5. Click Save.
  6. 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.

Questo articolo ti è stato utile?

Articoli correlati

Still need a hand?

Open a ticket and we will reply by email. The whole team sees your request.