Password Protect Directories

How to Password Protect a Directory in cPanel

 

You can restrict access to any folder on your hosting account so that visitors must enter a username and password before viewing its contents. This is useful for protecting admin areas, staging sites, private files, or members-only sections.

 

Steps to Set Up Password Protection

  1. Log into your cPanel hosting control panel
  2. In the Files section, click Directory Privacy
  3. Navigate to and select the folder you want to protect
  4. Check the box for Password protect this directory
  5. Enter a name for the protected directory (this will appear in the login prompt visitors see)
  6. Click Save
  7. On the next screen, create a username and password for access

 

Once configured, anyone who visits that directory in their browser will be prompted with a login dialog box before the page loads.

 

What Happens Behind the Scenes

When you password protect a directory, cPanel creates a .htaccess file and a .htpasswd file for that directory. The .htaccess file tells the server to require authentication, and the .htpasswd file stores the encrypted credentials. You can also set this up manually via .htaccess if you prefer more control over the configuration.

 

Adding Multiple Users

You can create multiple usernames for the same protected directory. Each user will have their own login credentials. Go back to the Directory Privacy settings for that folder and add additional users as needed.

  • 444 Users Found This Useful

Was this answer helpful?

Related Articles

Why can I not ping my domain?

Why You Cannot Ping Your Domain   If the ping command does not respond when you try to ping...

Add Flash Chat to your Website

Flash Chat and Adobe Flash   Adobe Flash was permanently discontinued and all major browsers...

How can I change the index listing in a directory?

You can change the initial page that is sent to client requests when a directory is accessed by...

Point Multiple Domains to the Same Website

Pointing Multiple Domains to One Website   To have several domain names all display the same...

What is a Top-Level-Domain (TLD)?

What is a Top-Level Domain (TLD)?   A Top-Level Domain (TLD) is the last part of a domain...



Save 30% on web hosting - Use coupon code Hosting30