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

Reseller: Unable to find an IP address in when creating an account

Reseller Error: Unable to Find an IP Address When Creating an Account   This error occurs in...

Meta Redirect

Adding this code to your web page will redirect your visitors to any address that you have...

Common Search Engine Optimization Tips

Get other websites to link to you. Have your website linked and posted in socal media...

Add Flash Chat to your Website

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

Point my domain to my wix account

Pointing Your Domain to a Wix Account   If you want to use Wix for your website while...



Save 30% on web hosting - Use coupon code Hosting30