KB: How to Password Protect Directories in cPanel
You can password protect a directory on your website to restrict access to its contents. This is useful for securing private information, staging sites, or any content you only want specific people to see. This guide will walk you through the process using cPanel's Password Protect Directories function.
Step 1: Access cPanel
First, log in to your cPanel account. The login URL is typically yourdomain.com/cpanel.
Step 2: Navigate to Directory Privacy
In cPanel, find the Files section and click on Directory Privacy.
Step 3: Select the Directory to Protect
You'll see a list of your website's directories. To protect a folder, click on its name. For example, to protect a folder named private located in your main website directory, click the folder icon next to /public_html. Then, click the name of the private folder.
Step 4: Configure Protection Settings
On the next page, you'll see a checkbox and a text field.
Check the box: Select the checkbox that says "Password protect this directory."
Name the protected directory: In the text field, enter a name for the protected area (e.g., "Authorized Access Only"). This name will be displayed in the browser's authentication window.
Click Save: Click the Save button. A confirmation message will appear.
Step 5: Create a User
After saving the protection settings, you need to create a user who can access the directory. Scroll down to the Create User section on the same page.
Username: Choose a username for the new user.
Password: Create a strong password. You can use the Password Generator to create a secure password automatically.
Confirm Password: Re-enter the password to confirm it.
Click Save: Click Save to create the user.
How It Works
Once you've completed these steps, any user attempting to access the protected directory will be prompted with a login box. They will need to enter the username and password you created to view the contents.
To grant access to more people, you can create additional users for the protected directory by repeating Step 5. To remove access for a user, simply delete their username from the list in the same menu.