How to Password Protect Folders Using Directory Privacy in cPanel

45 views
Short answer: Launch Directory Privacy in cPanel, select the target folder, check 'Password protect this directory', create an authorized user credential, and click 'Save'.

Learn how to secure sensitive directories and admin folders with HTTP Basic Authentication using cPanel Directory Privacy without writing complex .htaccess code.

Quick reference

Tool Name Directory Privacy (Files section)
Mechanism Apache HTTP Basic Authentication (.htpasswd)
Impact Prompts browser popup dialog before loading any page or file in directory

Steps

  1. Open Directory Privacy: In cPanel, navigate to Files > Directory Privacy.
  2. Locate the Target Folder: Click through your directory tree (e.g., inside public_html) and click the name of the folder you wish to protect (e.g., secret-files or staging).
  3. Enable Protection:
    • Check the box: Password protect this directory.
    • Enter a display name in Enter a name for the protected directory (e.g., Restricted Area). This text appears in the browser authentication popup.
    • Click Save.
  4. Create Authorized User: Return to the folder settings page, scroll down to Create User:
    • Enter a Username and a strong Password.
    • Click Save. You can create multiple authorized users with independent passwords for team members.

Troubleshooting and tips

  • WordPress AJAX Broken (401 Error): Password-protecting the entire wp-admin folder may block frontend AJAX calls that query wp-admin/admin-ajax.php. If your site features dynamic carts or search, exempt admin-ajax.php inside .htaccess.
  • Browser keeps prompting: Clear your browser cache or test in an Incognito window to reset stored credentials.
Need more help? If you run into an error while following these steps, open a ticket with technical support and our team will look into it. Open a ticket
Was this article helpful?
No, I need more help
Didn't find your answer?
Under 3 minutes
Submit Support Ticket