How do I password protect a directory?

You can password protect directories within your web site from unauthorized users by using "Web Protect". This allows you to restrict material to only authorized users.

To password protect a directory the following steps will need to be completed:

  1. Click on the "Web Protect" link under the "Site Management" header in cPanel.
    Navigate to the directory that you want to protect. Select a folder by clicking on the folder name link, or open a folder by clicking on the folder icon.
  2. Click on the tick box next to the LOCK icon. (Make sure you do this, most people miss this step)
    Enter the name that you want to appear in the "Protected Resource Name" field.
  3. Click on the Save button.


Generally, you now need to add at least one authorized user to enable access to the directory. Refer to "Adding an authorized user" for more information. When you check to make sure your password protect is working, please exit out of all of your browser windows, to insure that you are not suffering from browser caching issues.


* Please note that following a cPanel bug, the ~/.htpasswd directory along with sub-directories & files within won't have the proper permissions. 

Symptoms;
Following the setup, you may experience a 500 Internal Server Error.

Solution;
In order to resolve that issue, simply change the group ownership to "nobody" recursivly.

From a terminal, issue the following command:
chown $(whoami):nobody ~/.htpasswds -R

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to delete files and folders

It is easy to delete a file, but sometimes it is not what you would like to actually do. In order...

How to create files and folders

In order to create a new folder from your File Manager, please go to your www folder and click...

How to change file permissions

In order to change the permission of a file, the first thing you need to do is to login to your...

Creating Backups

What are Backups?Backups allow you to download (to your computer) a zipped copy of either you...

How to create FTP accounts

To create a new FTP account from the cPanel, please click the FTP Manager icon. Select the FTP...