Directory password protection is a feature of the cPanel service that will allow you to protect a directory from unauthorized access. The idea behind this functionality is to delegate access towards specific people you want to work on the website (developers, designers, etc) or to completely restrict the website temporarily to the public audience until work on it.
The feature works by prompting a login form and requiring the visitor to enter a username and password. If those are correct the content of the folder will be displayed, if not, an appropriate error message will be shown.
This feature is particularly useful when you would like to protect any sensitive directories on your web hosting account, such as:
Let’s get into the “Directory Privacy” cPanel feature!
As noted, “Directory Privacy” is a cPanel feature, and as such, you will need to access the cPanel for your Web Hosting Account in order to access it. If you are not quite sure how to login into your cPanel service, please check our other tutorial about How to access the cPanel service.
From within the cPanel service, the “Directory Privacy” feature is available right under the “Files” category of features.
Once you click on the feature you will be redirected to a new page where you will be able to further configure the “Directory Privacy”.
The newly opened page contains some basic information about what the “Directory Privacy” feature. In addition to that it will list all directories on your cPanel account. They will be tidily arranged in a table section and corresponding to each directory, you will see an “Edit” button that will allow you to set up the directory privacy feature.
Here is the place where we should make a small note. As we mentioned at the beginning of this tutorial, the “Directory Privacy” feature will protect folders that are only accessible via the web. This means that the protected directory should be under the document root of either your primary domain or any of the other domains/subdomains you have added to your Web Hosting Account. If the protected directory is located outside the directory root for your domain, then this folder cannot be accessed via the web(web browsers, such as Chrome or Firefox), and the goal of the feature cannot achieve its goal.
Let’s continue by selecting a folder that we will be protecting. In our case, this will be the “wp-admin” folder inside the “public_html” directory of our sample cPanel Web Hosting Account. To do that, please click on the “Edit” button, corresponding to the folder in question.
After performing the action above, you will be redirected to the page allowing you to add password protection for the directory. Eventually, when this is done you will be redirected to the final page, where you will configure the remaining settings.
On the new page, you will be provided with a few important settings. First, to enable the “Directory Privacy” for the selected folder you will have to tick the “Password protect this directory” check box and specify the name of the protected directory.
When you are ready, please click on the “Save” button in order for the “Directory Privacy” to take effect. cPanel will save the configuration and will then display a message indicating the successful enabling of the “Directory Privacy” feature.
Congratulations! You have successfully enabled the “Directory Privacy” feature! However, this is only half the work done. Let us see how to create a user that will be authorized to view the content of that folder.
As we have already mentioned the “Directory Privacy” feature does require authorization for a protected folder to be opened over the web. The authorization is considered complete when the username and password credentials are typed into the respective login forms. To create the mentioned credentials, please go back to the previous page where you created the password-protected folder.
The second half of the page is precisely for creating and assigning user access to the password-protected folder. To create a new user, please specify the username and the password in the “Create User” section.
When you have typed in the credentials in their respective fields, please click on the “Save” button so the user can be created. Afterward, cPanel will then create the user, assign it to the folder and finally provide a message indicating the successful operation.
That’s it! You are ready to access the folder in your web browser! Just in case you lose the password or you would like to change it, simply access the same configuration page for the password-protected folder and add the user anew with the new password you would like to use.
Congratulations! You now know how to completely protect a directory on your web hosting account from unauthorized access. Of course, if you experience any difficulties enabling the directory protection feature, please reach out to our Technical Support Team, and they will gladly assist you with your goal!
Nikola is an accomplished tech-savvy extraordinaire with over six years of experience in the web hosting field. He started as a customer care representative and quickly rose the ranks to become a support supervisor and, eventually - the head of the technical department in HostArmada. His deep understanding of the client's needs, combined with his technical knowledge, makes him the perfect man to create the ideal harmony between client satisfaction and professional problem-solving. You will often find him creating helpful tutorials, articles, and blog posts that help existing customers get around.