Password-protecting a directory adds a browser login prompt before anyone can access it. This is useful for staging sites, admin areas, or private client portals.
Enabling Directory Privacy in cPanel
Go to Files > Directory Privacy. Navigate to the folder you want to protect, click its name, check Password protect this directory, enter a label (shown in the browser prompt), and click Save.
Adding an Authorised User
Scroll down to Create User. Enter a username and password, click Save. You can add multiple users for the same directory β useful for team access.
How it Works Under the Hood
cPanel creates an .htaccess file in the directory and an .htpasswd file containing the encrypted credentials. The directory prompt appears whenever a browser requests any file in that folder.
Removing Password Protection
Return to Directory Privacy, click the folder, uncheck Password protect this directory, and save. The .htaccess rules are removed automatically.