If you have provided login access to your cPanel to multiple people, you might want to consider password protecting some directories. If you password protect a directory, it will prevent others from accessing certain directories and it will improve the overall security of your website
After all, it will cause issues for any hackers that end up there as well.
Password protection allows you to control access to content that you do not want to be publicly available, and it prevents Google and other search engines from discovering and indexing the content.
Today, I will demonstrate how to password protect a directory on your website using cPanel.
Why Password Protect a Directory?
Commonly used to protect downloads, files, or pages that you only want specific people to access, learning how to password protect directories will pay dividends for as long as your websites last. This will help restrict content when you don’t want it made publicly available.
Let’s go over the process of password protecting directories in cPanel together.
How to Password Protect A Directory
Step 1: Click on Directory Privacy
Before beginning, you will need access to the cPanel of your website. This information is provided to you by your web host. The process is very quick, so let’s begin.
Log in to cPanel, and locate the Files section. Click the Directory Privacy option.
Step 2: Click on Edit
You will now see a full list of all of your website’s directories. You can click on a directory to access its subdirectories, which can also be password protected.
On the right-hand side of a directory, you will notice an “Edit” button. This will allow you to make the directory password protected.
Note: There is a “Private” column that will tell you if the directory already has a password or not.
Click on the “Edit” button for the directory you wish to add password protection to.
Step 3: Enter A Name for the Directory
There are two steps to password protecting a directory. The first involves picking a name for your directory.
Check the small checkbox to “Password protect this directory” and it will unlock the textbox below it. In this textbox, you must enter a name for the directory.
Note: This does not have to be the actual name of the directory. It will automatically add Protected ‘your directory name’ in this text spot, which will suffice for most websites.
Click on the “Save” button when you are done.
You will now see a success notification signaling that everything happened correctly. Click the Go Back link below it.
Step 4: Password Protect the Directory
The second part of the process is to create a new user that can access the directory. Be aware that if your web browser has autofill turned on, it will enter your information into the fields. This cannot be the same as your information. You must enter a new user name and password.
Make sure that you write down this unique user’s login information. It can cause a lot of problems if lost.
Note: The system will analyze your password or passphrase and reject it with a “password strength” error if it is too short or not sufficiently complex. If you need help making a strong password, check out this tool.
Once you have filled in the necessary information, click the “Save” button.
You will once again see the success message, indicating that your directory is now password protected.
Congratulations on password protecting your directory.
What’s Happening Behind the Scenes
cPanel creates two files when it password protects a directory. You get a “.htaccess” file in the directory being protected. You also get a “passwd” file outside of the publicly viewable structure of your website. This is in the .htpasswds directory above your home directory.
It’s important that the .htaccess file in the directory being protected is not deleted while you’re working on your site. This also applies to the passwd file. However, it’s unlikely that you’ll accidentally delete this file.
If either of the files is deleted, the directory will no longer be password protected. You will need to repeat this process to reinstate protection.
Is any section of your website password protected? Now that you know how easy it is to protect a directory, do you think you’ll use this tool?
Author: Michael Phillips
Michael Phillips is a web hosting industry veteran, helping people make the most of their web presence since 1995.