Password Protect a Folder in cPanel (Video Guide)
Some folders on a site are not for everyone: a client area, a draft section, or files you share with one customer. Directory Privacy in cPanel puts a username and password in front of a folder, so only the people you choose can open it. This video shows how, and the steps below follow it.
One warning first
If you protect the main web folder (public_html), you protect the whole website, including the home page. That is rarely what you want. Protect a subfolder instead, such as one for clients or for a preview. You can find the exact folder name in the File Manager, as our File Manager video shows.
Step by step
- Sign in to cPanel and open Directory Privacy in the Files section.
- Click the folder name to open it, until you see the folder you want. Click Edit next to it.
- Tick Password protect this directory.
- Type a name for the protected area. Visitors see this name in the password box, so keep it plain.
- Click Save.
- Create a user: type a username, type a password twice and click Save.
Video transcript
This video shows how to password protect a folder in cPanel. We open Directory Privacy and click Edit next to the folder we want to protect. We tick Password protect this directory, type a name for it, then click Save. Then we create a user with a username and a password.
Test it
Open the folder address in a private browser window. You should see a small box that asks for a username and a password. Enter the details you created, and the folder opens. If it opens with no box, the protection was not saved, or you opened a different folder. Go back to Directory Privacy and check the folder again.
Good habits
- Give each person their own user. Then you can remove one person without changing the password for everyone.
- Use a different password for each folder. Our guide on strong passwords has easy ways to make one.
- Do not reuse the password of your email or cPanel.
- When a folder no longer needs protection, open Directory Privacy, click Edit, untick the box and save.
Common problems
- The password is rejected: check the spelling of the username. It may be case sensitive.
- The whole site asks for a password: you protected the main web folder. Edit it and untick the box.
- The folder opens with no box: the protection was not saved, or the folder is outside the one you protected.
What this does not do
A password box keeps casual visitors out. It is not a full security system. Keep sensitive data away from public folders, and read our guide on WordPress security basics for more habits. A private subfolder works well with a subdomain too. See how to create a subdomain in cPanel.
Also take a backup before you change how a site works. See our website backups guide.
FAQ
Will search engines see a protected folder?
They cannot open it without the password, so its pages are normally not read.
Can I add more people later?
Yes. Repeat the create user step with a new username.
How do I remove someone?
Delete their user in the list. Their access ends.