How to password protect directories and files on your site from cPanel?

Sometimes we may have files and folders on our websites that we’d like to keep secret from public access. There are several ways to protect your files and privacy if you are a programmer. Most of them requires some level of coding knowledge. Fortunately you can easily password protect directories and files easily in cPanel without any additional scripts or skills. If you are using a cPanel web hosting, follow this guide to get started.

How to set password protection on your site from cPanel?

Login cPanel using your account credentials. Scroll down to the Security section in cPanel home page. Find and click Password Protect Directories. See below screenshot.

cpanel security password protect directories

You will then get a pop-up window where you can choose a site which has the folder(s) you like to add a password to. You can also choose Web Root to browse to the directory you like to protect.

password protect directories - select website in cpanel

Now we come to the page to choose the specific directory which we like to protect using a password. Click the name of the folder that you wish to protect to select it. If it is a sub-folder, click a folder’s icon in front of the folder name to open it and find all sub-folders beneath until you find the target directory.

password protect directories - select folder in cpanel

We will be taken to the last page to finalize the password protection in cPanel. Here we need to do two things: 1) enable password protection on the selected directory; 2) create a user to access the protected folder.

  • Password protect this directory: click the checkbox to enable it;
  • Enter a name for the protected directory: this name will display along with the authentication prompt when someone trying to access the protected folder. You can choose a descriptive name such as ‘for accounting staff only’, ‘students login’, ‘for teachers’, ‘family album’, ‘honey moon’. Using a descriptive name is useful when you want to restrict the access to some members in an organization.
setup password protect directories in cpanel

Do not forget to create a user who can access the protected folder on your site. Make sure to set up a complicate password. You can make use of the strength score bar to confirm its difficulty.

Now anyone trying to access your protected directory from the web or a web browser, he or she will be required to verify the username and password. This is useful when you need to limit access to a certain part of your site.

password protect website directory

Leave a Reply