Adding password protection to directories
Last Updated: December 25, 2025
Occasionally, you may want to host information on your website that is only accessible to authorized users. To do this, you can add password protection to specific folders or directories. Once enabled, any visitor attempting to access that part of your site will see a pop-up requesting a username and password. The content will not load until the correct credentials are provided.
How to enable password protection
- Log into cPanel.
- Navigate to the Files section and click File Manager.
- Locate the folder you wish to secure. Right-click the folder and select Password Protect (this will open the Directory Privacy menu).
- In the Security Settings section, check the box labeled Password protect this directory.
- Enter a display name for the protected directory; this is the label visitors will see in the login pop-up.
- Click Save.
How to create authorized users
After you have enabled protection, you must authorize specific users to access the folder.
- On the same Directory Privacy page, scroll down to the Create User section.
- Input a username and password.
- Note: We recommend using the Password Generator to ensure a high level of security.
- Click Save or Add/Modify authorized user.
- You can repeat this process to add multiple users with unique credentials.
Important tips for success
- Verify the protection: Open your website in a Private or Incognito browser window to test the password. Browsers often cache login credentials, which can make it appear as though the protection isn't working.
- Subdirectories: When you password protect a folder, all subfolders inside of it are also automatically protected with the same credentials.
- Configuration files: Enabling this feature creates or modifies an .htaccess file within the directory. Do not delete this file, or the password protection will be removed.
