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

When I type in my domain it goes to ultrawebhosting.com

My Domain Redirects to ultrawebhosting.com   If typing your domain name takes you to the...

Meta Redirect

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

Why do I get emails for cron jobs?

Stopping Emails From Cron Jobs   By default, cron sends you an email with the output of...

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

Sub-Domain times out

Sub-Domain Not Loading or Timing Out   If your subdomain is timing out or not loading, there...



Save 30% on web hosting - Use coupon code Hosting30