You can password protect a folder in cPanel in about five minutes, which is useful for a staging site, client files, or a private downloads area. This guide covers cPanel’s built-in Directory Privacy tool, from choosing the folder to creating the login and testing it.
It is written for anyone with a cPanel hosting account, and you don’t need to write any code. The steps are based on cPanel’s official Directory Privacy documentation (cPanel version 88 and later, last updated July 2026). Your host may use a customized theme, so menu names can differ slightly.
What You Need Before You Start
- Your cPanel login details, or access to cPanel through your host’s client area.
- Access to the Directory Privacy tool. Your host can turn it on or off for each plan.
- The folder you want to protect, already created in your account (for example, a folder inside
public_html). - A recent backup of the folder’s
.htaccessfile, or a full account backup. - A password manager to store the new username and password.
If your current plan doesn’t include cPanel, or you’re unhappy with your host, compare your options in our guide to the best WordPress hosting providers.
How Password Protecting a Folder in cPanel Works
Directory Privacy puts a login prompt in front of a folder. When someone opens a page or file inside that folder in a web browser, the server asks for a username and password before showing anything.
According to cPanel’s documentation, the tool works by editing the folder’s .htaccess and .htpasswd configuration. You never have to edit those files by hand.
- Subfolders are covered too. A protected folder’s subfolders inherit its password protection.
- It only protects browser access. It does not block access through FTP, SFTP, Web Disk, or other services.
- A lock icon marks protected folders. It shows that Directory Privacy settings already exist for that folder.
- The protected name is just a label. It does not rename the folder or change its URL.
Because it only applies to web visitors, Directory Privacy suits staging sites, client review areas, and private download folders. It does not replace strong FTP passwords or correct file permissions.
Back up first
Directory Privacy edits the .htaccess file in the folder you protect. Download a copy of that file or run a full backup before you start, so you can restore it if anything breaks.
Step 1: Open Directory Privacy in cPanel
On most cPanel installs, Directory Privacy is in the Files section of the home page. cPanel’s documentation notes that hosts can disable the tool, so it may be missing on some plans.
- Log in to cPanel, either directly or through your host’s client area.
- Scroll to the Files section on the cPanel home page.
- Click Directory Privacy. If you can’t see it, type “Directory Privacy” into the cPanel search box.
Menus vary by host
Some hosts use a customized cPanel theme or rename sections. If Directory Privacy is not under Files, use the search box or ask your host whether the feature is enabled on your plan.
Step 2: Choose the Folder You Want to Protect
Directory Privacy opens with a list of the folders in your account. Clicking a folder’s name takes you into it, and the Edit link opens its security settings.
- Click a folder’s name to open it and see its subfolders. Your website files are usually inside
public_html. - Keep clicking folder names until you reach the folder you want to protect.
- Click Edit in the Actions column next to that folder.
If a folder already has a lock icon, it has existing Directory Privacy settings. Check those settings before you change anything, since someone may already rely on that login.
Do not protect public_html by accident
If you protect public_html itself, every page on your website will ask visitors for a password. Double-check the folder before you save, especially on a live site.
Step 3: Turn On Password Protection
This step switches protection on for the folder. cPanel’s documentation is clear that nothing changes until you click Save, and nobody can log in until you create a user in Step 4.
- Under Security Settings, check the Password protect this directory box.
- In the Enter a name for the protected directory box, type a short label, for example
Staging Area. - Click Save. A confirmation message appears.
- Click Go Back to return to the folder’s settings.
The name you entered is only a label stored in the folder’s .htaccess file. Pick something that will help you recognize the folder later.
Step 4: Create a User Who Can Access the Folder
Next, add at least one username and password. Without a user, the folder is locked but no one has a working login, including you.
- In the Create User section, type a username in the Username box.
- Enter a password, then type it again in the confirmation box.
- Or click Password Generator to have cPanel create a strong password, and copy it somewhere safe.
- Check the Strength meter. Green means the password meets your host’s minimum.
- Click Save, then click Go Back.
cPanel scores passwords on a scale from 0 to 100, and some hosts require a minimum score. If your password is rejected, make it longer or use the generator.
Use a separate login
Do not reuse your cPanel or WordPress password here. Use a unique password, store it in a password manager, and send it to clients through a secure channel rather than plain email.
Step 5: Manage Who Can Access the Protected Folder
You can come back at any time to add people, change a password, or remove access. The folder’s settings page lists everyone who can log in under Authorized Users.
Add another user
- Open Directory Privacy, browse to the folder, and click Edit.
- Repeat Step 4 with a new username and password.
Change a user’s password
- In the Create User section, enter the existing username and the new password.
- Click Save. cPanel replaces the old password with the new one.
Remove a user
- In the Authorized Users list, select the user.
- Click Delete User, then click Go Back.
How to Check It Worked
Test the protection in a fresh browser session. Your regular browser may already be logged in or have the page cached, which can hide whether the login prompt works.
- Open a private or incognito browser window.
- Go to the protected folder’s URL, for example
https://example.com/staging/. - Confirm that the browser asks for a username and password.
- Cancel the prompt. You should see an error page, often a 401 Unauthorized message, instead of the folder’s content.
- Reload the page, enter the username and password from Step 4, and confirm the content loads.
- Open a subfolder URL as well, to confirm it is protected too.
If all of this works, your folder is protected. Browsers usually remember the login until you close the window, so open a new private window each time you retest.

ScalaHosting
The best all-around web host for performance, security, and support, independently owned and built around its own SPanel technology.
- SPanel control panel
- SShield security
- Managed cloud VPS
- Flexible scaling
- Independent ownership
* Introductory price. Renewal rates apply. Anytime money-back guarantee.
Check out my ScalaHosting Review and grab the latest discount on my #1 web hosting pick for 2026.
If you want more detail before switching, read our HostArmada review for a closer look at its plans and support.
Troubleshooting Password-Protected Folders in cPanel
Why can’t I create a user for the protected folder?
According to cPanel’s documentation, the folder needs the correct permissions before you can add users. If user creation fails, change the folder’s permissions to 0700 in File Manager, then try again.
- Open File Manager from the Files section.
- Right-click the folder and choose the permissions option. Note the current value first so you can restore it if needed.
- Set the permissions to
0700, save, and return to Directory Privacy.
Why doesn’t the password prompt appear?
The most common cause is that your browser is already logged in or is showing a cached copy. A caching plugin or CDN can also serve a stored version of the page, so the prompt never reaches the visitor.
Test in a new private window, make sure the lock icon is on the correct folder, and purge any site or CDN cache. If the prompt still doesn’t appear, ask your host to check the server configuration.
Why is Directory Privacy missing from my cPanel?
Your host controls which cPanel tools are available, and it may have turned this one off for your plan. Ask support to enable it.
If your host won’t enable it, a plan with full cPanel access may suit you better. Our InMotion Hosting review covers one cPanel-based option.
Why does my whole website ask for a password?
You most likely protected public_html or another top-level folder. Open Directory Privacy, click Edit next to that folder, clear the Password protect this directory box, and click Save.
Why does the login keep failing?
Check for typos and extra spaces, and note that usernames may be case-sensitive. If you’re still locked out, set a new password for that user as shown in Step 5, then test again in a private window.
FAQ
Does password protecting a folder in cPanel block FTP access?
No. Directory Privacy only protects access through a web browser, so anyone with FTP, SFTP, or Web Disk credentials can still reach the files. Keep those logins secure separately.
Are subfolders protected automatically?
Yes. Subfolders inherit the protection of the folder above them, so one login covers everything inside the protected folder.
How do I remove password protection from a folder in cPanel?
Open Directory Privacy, click Edit next to the folder, clear the Password protect this directory box, and click Save. The folder becomes publicly accessible again.
Can more than one person access the protected folder?
Yes. You can create as many users as you need, each with their own username and password, and remove them individually later.
Is Directory Privacy secure enough for sensitive files?
It is a solid basic barrier for staging sites and client areas, but use it only on a site served over HTTPS, because the browser sends the login with its requests. Keep highly sensitive data out of public web folders entirely.
Next Steps
Now that your folder is protected, review your FTP accounts and backups so the rest of your hosting is just as tidy. If you need more control than shared hosting gives you, our ScalaHosting review covers its managed VPS plans.
Still deciding between cPanel hosts? See how HostArmada compares to InMotion Hosting.















