Password-protect a folder on your website
Updated 27 Nov 2026
With Directory Privacy in cPanel, a folder on your website asks for a username and password before showing anything. It's a quick way to hide a test version of your site, a staff downloads page or a folder of reports.
Turn it on
- Open Services, choose your hosting and press Login to cPanel.
- Under Files, open Directory Privacy.
- Click the folder names to go to the folder you want to protect. For example, click public_html, then press Edit next to the folder
staff. - Tick Password protect this directory.
- In Enter a name for the protected directory, type a short label, for example
Bethel staff area. Visitors see this in the login box. - Press Save, then Go Back.
Create a login
The folder now asks for a password, but nobody has one yet.
- On the same page, under Create User, enter a Username, for example
staff. - Enter a New Password, or press Password Generator and copy it somewhere safe.
- Press Save.
Open https://yourdomain.co.tz/staff in a private browser window. A box asks for the username and password.
You can add several users, one for each person. To remove someone's access, select their name under Authorized Users and press Delete User.
Good to know
- Everything inside is protected, including sub-folders and files.
- Protecting public_html protects your whole website. That's useful for a site that isn't ready yet, but remember to turn it off on launch day.
- Use HTTPS. Open the folder at
https://, so the password isn't sent in plain text. See Turn on free SSL (HTTPS) for your website. - The browser remembers the login until it is closed. To test again, use a new private window.
- These logins are separate from your cPanel, email and WordPress passwords.
Protecting the WordPress admin area
You can protect wp-admin this way as an extra lock, but it can break features that use wp-admin/admin-ajax.php, such as contact forms and shop carts. A security plugin with two-step login is usually a better choice for WordPress.
Turn it off
- Open Directory Privacy and press Edit next to the folder.
- Untick Password protect this directory and press Save.
The users you created stay, so you can turn protection back on later without making new logins.
Stuck? Open a ticket and choose Technical. Our team can do it for you. Not hosting with us yet? See our cPanel hosting plans.