SimonHosting
  • Best Web Hosting
  • Reviews
  • Deals
  • Comparisons
  • Tutorials
No Result
View All Result
Best Web Hosting
SimonHosting
  • Best Web Hosting
  • Reviews
  • Deals
  • Comparisons
  • Tutorials
No Result
View All Result
SimonHosting
No Result
View All Result

How to Password-Protect a Website Folder Using cPanel

Alfredo Vilar by Alfredo Vilar
October 17, 2026
in Tutorials
How to Password-Protect a Website Folder Using cPanel
📋Editorial transparency: Some links in this guide are affiliate links; if you purchase, we may earn a commission at no extra cost to you. This never influences our recommendations or the instructions we publish.

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 .htaccess file, 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.

  1. Log in to cPanel, either directly or through your host’s client area.
  2. Scroll to the Files section on the cPanel home page.
  3. 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.

  1. Click a folder’s name to open it and see its subfolders. Your website files are usually inside public_html.
  2. Keep clicking folder names until you reach the folder you want to protect.
  3. 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.

  1. Under Security Settings, check the Password protect this directory box.
  2. In the Enter a name for the protected directory box, type a short label, for example Staging Area.
  3. Click Save. A confirmation message appears.
  4. 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.

  1. In the Create User section, type a username in the Username box.
  2. Enter a password, then type it again in the confirmation box.
  3. Or click Password Generator to have cPanel create a strong password, and copy it somewhere safe.
  4. Check the Strength meter. Green means the password meets your host’s minimum.
  5. 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

  1. Open Directory Privacy, browse to the folder, and click Edit.
  2. Repeat Step 4 with a new username and password.

Change a user’s password

  1. In the Create User section, enter the existing username and the new password.
  2. Click Save. cPanel replaces the old password with the new one.

Remove a user

  1. In the Authorized Users list, select the user.
  2. 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.

  1. Open a private or incognito browser window.
  2. Go to the protected folder’s URL, for example https://example.com/staging/.
  3. Confirm that the browser asks for a username and password.
  4. Cancel the prompt. You should see an error page, often a 401 Unauthorized message, instead of the folder’s content.
  5. Reload the page, enter the username and password from Step 4, and confirm the content loads.
  6. 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.

Hosting offer: ScalaHostingMy #1 Hosting Pick
ScalaHosting logo

ScalaHosting

9.8/10 overall

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
Up to
75% OFF

plans from $2.95/mo

Visit ScalaHosting↗ View offer on provider website

* 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.

  1. Open File Manager from the Files section.
  2. Right-click the folder and choose the permissions option. Note the current value first so you can restore it if needed.
  3. 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.

Read next

  • Best WordPress Hosting Providers
  • HostArmada Review
  • HostArmada vs InMotion Hosting

You might also like

How to Set Up a 301 Redirect in cPanel and Test the Destination

How to Set Up a 301 Redirect in cPanel and Test the Destination

October 17, 2026
How to Use the Zone Editor to Add or Edit DNS Records

How to Use the Zone Editor to Add or Edit DNS Records

October 17, 2026
How to Change Your cPanel Password and Update Contact Information

How to Change Your cPanel Password and Update Contact Information

October 17, 2026
How to Enable Two-Factor Authentication for Your cPanel Login

How to Enable Two-Factor Authentication for Your cPanel Login

October 17, 2026
Alfredo Vilar

Alfredo Vilar

Alfredo Vilar reviews web hosting, VPS, and managed cloud services. He has 10 years of expertise in WordPress and nearly a decade of experience as a cloud engineer. He focuses on real-world performance rather than marketing claims, and he has worked with many providers. He is experienced with cPanel, web development, AI-assisted coding, Astro, VPS setups, and hosting scalability. He also runs the YouTube channel SimonHosting (2K subscribers), where he has covered cloud, web hosting, and website development for over four years.

Related articles

How to Set Up a 301 Redirect in cPanel and Test the Destination

How to Set Up a 301 Redirect in cPanel and Test the Destination

by Alfredo Vilar
October 17, 2026

Editorial transparency: Some links in this guide are affiliate links; if you purchase, we may earn a commission at no...

How to Use the Zone Editor to Add or Edit DNS Records

How to Use the Zone Editor to Add or Edit DNS Records

by Alfredo Vilar
October 17, 2026

Editorial transparency: Some links in this guide are affiliate links; if you purchase, we may earn a commission at no...

How to Change Your cPanel Password and Update Contact Information

How to Change Your cPanel Password and Update Contact Information

by Alfredo Vilar
October 17, 2026

Editorial transparency: Some links in this guide are affiliate links; if you purchase, we may earn a commission at no...

How to Enable Two-Factor Authentication for Your cPanel Login

How to Enable Two-Factor Authentication for Your cPanel Login

by Alfredo Vilar
October 17, 2026

Editorial transparency: Some links in this guide are affiliate links; if you purchase, we may earn a commission at no...

Next Post
How to Check Disk Usage and Find Large Files in cPanel

How to Check Disk Usage and Find Large Files in cPanel

Recommended

ScalaHosting Review 2026 My Honest Test After 1 Year

ScalaHosting Review 2026: My Honest Test After 1 Year

ScalaHosting Coupon 2026_ Early Black Friday Deal

ScalaHosting Coupon 2026: Early Black Friday Deal

October 28, 2026
Best Managed VPS Hosting Deals 2026: Up to 73% Off

Best Managed VPS Hosting Deals 2026: Up to 73% Off

October 28, 2026
Thamara Cloud Review

Thamara Cloud Review 2026: Pricing, Lifetime Plans and Real Risks

October 28, 2026
Best Cheap Hosting

Best Cheap Hosting 2026: 6 Affordable Hosts Compared

October 18, 2026
How to Enable Two-Factor Authentication for Your cPanel Login

How to Enable Two-Factor Authentication for Your cPanel Login

October 17, 2026
Best VPS Hosting

Best VPS Hosting in 2026: 10 Top Providers Compared

October 18, 2026
Black Friday Offer: ScalaHostingMy #1 Pick
ScalaHosting logo

ScalaHosting

9.8/10 overall

Managed Cloud VPS Hosting for bloggers, ecommerce, online businesses, and growing WordPress sites.

  • Dedicated CPU and RAM
  • Fully managed service
  • Free website migration
72% OFF

Entry Cloud plan

Claim 72% off↗ View offer on provider website

72% off the Entry Cloud plan. Check billing term, renewal pricing, and current provider terms.

  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions

No Result
View All Result
  • Best Web Hosting
  • Reviews
  • Deals
  • Comparisons
  • Tutorials