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

How can I turn off directory indexing?

In the directory that you wish you turn off directory indexing, you can do it under Index Manager...

How can I change the default page / document?

Create a .htaccess file, include the below information into it and upload it to the public_html...

Inode issues

There are many issues that can arise from reaching your inode limit. The inode limit is the total...

I can not get the transfer authorization email can it be forwarded to a different email address?

Transfer Authorization Email Not Arriving   If you cannot receive the domain transfer...

osCommerce password reset

How to reset your osCommerce admin login... You can reset your osCommerce administrative login...



Save 30% on web hosting - Use coupon code Hosting30