cPanel & Hosting How-Tos How to Password-Protect a Directory in cPanel
Sometimes part of your site should be private — a staging copy, an admin area, or a folder of files only certain people should see. cPanel’s Directory Privacy adds a username-and-password prompt to any folder in a couple of clicks. Here’s how.
What it does
When you protect a directory, anyone who tries to open it — or anything inside it — gets a browser login prompt first. Without the right username and password, they see nothing. It’s a quick, effective lock for non-public content.
Step 1: Open Directory Privacy
- In cPanel, open Directory Privacy (under Files).
- Browse to the folder you want to protect (for example
public_html/staging). - Click the folder’s name to open its settings.
Step 2: Turn on protection
- Tick Password protect this directory.
- Give it a name (shown on the login prompt, e.g. “Staging — Authorized Only”).
- Click Save.
Step 3: Create a user
The folder is now protected, but you need a login for it:
- Under Create User, enter a username.
- Set a strong password (use the generator).
- Click Save.
Now anyone opening that folder must enter this username and password.
Good uses for it
- Staging / development sites — keep a work-in-progress private and out of Google.
- Private downloads — share files with specific people only.
- An extra lock on a sensitive folder.
A note on WordPress
You can password-protect wp-admin for an extra layer, but it can interfere with some AJAX features (and plugins that rely on admin-ajax.php). For most sites, a strong admin password plus two-factor authentication is the better first step — see secure your hosting account with strong passwords and 2FA and our WordPress security checklist.
Simple privacy, built in
Directory Privacy is included on every Web Hosting and WordPress Hosting plan — a fast way to keep a staging site or private area away from the public and search engines, with no extra tools to install.
Frequently asked questions
What can I use directory password protection for?
It is ideal for a staging or development site you do not want public or indexed, a private download area, or an extra lock on a sensitive folder. Visitors must enter a username and password before they can see anything inside.
Does this protect a WordPress admin area?
You can password-protect the wp-admin folder for a second layer of security, but do it carefully - it can interfere with some AJAX features. For most sites, a strong password plus 2FA on WordPress is the better first step.
Will a protected folder still be indexed by Google?
No. Because the content is behind a login prompt, search engines cannot access it, so it will not be indexed. This makes it a simple way to keep a staging site out of search results.