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
- Open Directory Privacy: In cPanel, navigate to Files > Directory Privacy.
- 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-filesorstaging). - 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.
- 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-adminfolder may block frontend AJAX calls that querywp-admin/admin-ajax.php. If your site features dynamic carts or search, exemptadmin-ajax.phpinside.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