How to Password-Protect a Directory Using .htaccess in cPanel Print

  • 4

 

How to Password-Protect a Directory Using .htaccess in cPanel

If you want to restrict access to a specific folder on your website, cPanel allows you to password-protect a directory using a simple interface. This feature generates a .htaccess file that requires a username and password to access the directory and all of its subdirectories.

 

Steps to Enable Directory Protection

  1. Log in to your cPanel account.
  2. Click on the "Directory Privacy" or "Password Protect Directories" option.
  3. Navigate to the folder you wish to protect by clicking the folder icon next to public_html.
  4. Click on the folder name to open its protection settings.

 

Setting up Protection

  1. Check the option "Password protect this directory".
  2. Enter a name for the protected area (e.g., "Private Area").
  3. Click Save to activate the password protection.

 

Creating an Authorized User

  1. Choose a Username for login.
  2. Enter or generate a secure password.
  3. Click Save to finalize the setup.

Now, access to the folder will require the username and password you just created.

 

Important Note

Make sure to keep your credentials safe. After 7 consecutive failed login attempts, the server will temporarily block the IP address for security reasons.

 


Was this answer helpful?

« Back