Password protect website in cPanel

Some site owners may want to restrict access to the whole sites or specific sections, pages, or folders of their websites, permitting only designated users rather than the general public. In this case, you can protect the part of a site with a password. This can be achieved by manually configuring and editing the .htaccess and htpasswd files to control access to particular files and directories on the website. Alternatively, a user-friendly approach involves utilizing the password protection feature available within cPanel. This tutorial outlines the steps to effectively apply and remove password protection for a website or a directory using cPanel’s built-in password protection feature.

Password protect website or directories in cPanel

Please note that cPanel’s interface might vary slightly depending on your web hosting provider and the version of cPanel they offer.

Log in to cPanel through your web hosting provider’s portal or your own domain name, such as http://yourdomain.com/cpanel, with your username and password.

Locate the Files section in cPanel home interface.

cpanel files

Within the Files section, you should find an option named Directory Privacy or something similar. Click on it. You’ll see a list of directories.

cpanel files directory privacy

Select the directory you want to protect by clicking on the Edit button besides it. If you like to protect the whole website, you can apply protection to the root folder. Otherwise, browse to sub-directories of the site to find the directory you like to secure with password.

On the next page, you’ll find an option to “Password protect this directory.” Enable this option. You will be asked to provide a name for the protected directory. This name is what users will see when prompted for a username and password. Enter a descriptive name.

   

cpanel files directory privacy - enable password protection and create user

Click the Save button in the Security Settings section to enable the password protection. Then click the Back button to return to the Directory Privacy page. Now you will find the option to create user and password. You’ll need to create usernames and passwords for users who will have access to the protected directory. Finally click the Save button to create the user.

Once password protection is enabled, users who try to access the protected directory will be prompted for a username and password. They’ll need to enter the credentials you’ve set up to gain access.

Remove password protection

If you later want to remove the password protection, you can go to cPanel > Files > Directory Privacy, find the protected directory and edit it. Then delete all users you have created and turn off the Password protect this directory option and save the change to disable the password protection.