You have a staging copy of your site that visitors should not see, or a folder of files meant for clients only. Directory Privacy puts a simple lock on the folder: anyone who opens it gets a small browser prompt asking for login details, and without them they see nothing.
Stage one: choose the folder #
- Open Directory Privacy in the Files section of cPanel.
- Navigate to the folder click a folder name or icon to go inside it.
- Click Edit next to the folder you want to protect.

Stage two: turn protection on #
- Tick Password protect this directory on the Security Settings page.
- Enter a name for the protected directory visitors see it in the password prompt, such as Client Area.
- Click Save then Back to reach the user section.

Stage three: create a user #
Protection on its own locks everyone out. Create at least one user with a name and password. You can add several users to the same folder and remove any of them later without turning protection off.
What this protection suits #
| Good for | Not good for |
|---|---|
| A staging site or a site under construction | A customer login system with many accounts |
| A private downloads folder for your team | Protecting a single page inside WordPress |
| An extra layer on an admin folder | A replacement for updates and strong passwords |
admin-ajax.php, so parts of your site may break. Test on a staging site first.Removing protection #
Go back to the same folder, click Edit, untick protection and click Save. The tool writes its settings into the folder’s .htaccess file, so do not delete that file by hand or the protection disappears.
Frequently asked questions #
Does protection cover subfolders?
Yes, everything inside the protected folder needs the password.
I forgot the folder password. What now?
Open Directory Privacy and change the user’s password, or create a new user.
Does it protect against hacking?
It stops ordinary browsing only and does not replace updates and strong passwords.
Will it affect my Google ranking?
A protected folder is not indexed, which is usually what you want for a staging site.
- How to Stop Your Website Files Being Listed in the Browser (cPanel Indexes)
- Create an FTP Account in cPanel for a Developer or Staff Member, Limited to One Folder
- cPanel File Manager: Open It, Show Hidden Files, Change Permissions and More
- Exposed Sensitive Files on Your Site: .env, .git and Backups, and How to Hide Them
- The Files and Databases Sections in cPanel: File Manager, FTP and Creating a Database