How to Password-Protect Directories Using cPanel

Secure Private Sections of Your Website with Ease

Not all areas of your website should be publicly accessible. Whether you’re restricting access to admin panels, client portals, or development sections, password-protecting directories is a simple yet effective security measure.

cPanel provides a built-in tool to password-protect directories without requiring advanced coding or manual .htaccess configurations. This guide walks you through the process step-by-step.

Why Password-Protect a Directory?

There are several use cases for adding an extra layer of protection to specific folders on your website:

  • Restrict internal or development sections from public access

  • Secure confidential files or reports

  • Create private download areas for clients or team members

  • Protect access to third-party tools or software interfaces

By setting up password protection, users will need to enter valid login credentials before accessing the contents of the folder.

Step-by-Step Guide: Password-Protecting a Directory in cPanel

1. Log in to cPanel

Visit yourdomain.com/cpanel and sign in with your hosting account credentials.

2. Navigate to “Directory Privacy”

In the Files section, click on Directory Privacy. This is the tool that allows you to restrict access to folders.

3. Choose the Directory to Protect

  • A list of directories and folders in your hosting account will appear.

  • Click the folder icon to navigate through your directories.

  • Once you find the folder you want to protect (e.g., public_html/private), click Edit next to it.

4. Enable Password Protection

  • Check the box labeled Password protect this directory.

  • Enter a name for the protected area. This will appear as the title in the login prompt shown to users.

  • Click Save. You’ll see a confirmation that the protection is enabled.

5. Create a User for Access

Now that the directory is protected, you need to create at least one user who can access it.

  • Return to the same screen and scroll down to the Create User section.

  • Enter a username and a strong password.

  • Click Save.

Once saved, users must enter these credentials to access the protected folder through their browser.

How It Works

Once configured, any attempt to visit that directory (e.g., yourdomain.com/private/) via a web browser will prompt a login screen. Only users with valid credentials will gain access.

Additional Tips

  • Use strong passwords to prevent brute-force attacks.

  • Avoid protecting core folders unless necessary, such as public_html, as this may block your main site from loading.

  • Test access after setting it up to confirm that protection is active.

  • If needed, you can add or remove users anytime from the same Directory Privacy tool.

 

Removing Password Protection

To disable protection:

  • Go back to Directory Privacy in cPanel.

  • Locate the folder.

  • Uncheck Password protect this directory and save changes.

  • You may also delete the user account if no longer needed.

 

Conclusion

Password-protecting directories using cPanel is a fast and effective way to secure sensitive parts of your website. Whether you’re restricting a staging site, admin dashboard, or client area, this built-in feature gives you easy access control without needing technical expertise.

Use it wisely as part of your broader website security strategy to keep your content and data safe from unauthorized access.