Skip to main content
You can lock a folder of your website, such as a staging copy or a private downloads area, so the browser asks for a username and password first. This guide shows you how with Directory Privacy in cPanel.
This adds a simple browser login box. It’s good for keeping a test site or private files away from the public, but it isn’t a member login system. For WordPress member areas, use a WordPress plugin instead.

Lock the folder

1

Open Directory Privacy

Log in to cPanel, type Directory Privacy in the Search Tools box and open it.
2

Find the folder

Your website files are in public_html. Click folder names to open them until you see the folder you want to lock, then click Edit next to it.
3

Turn on protection

Tick Password protect this directory. Type a name for the protected area, such as Private area. Visitors see it in the login box. Click Save.
4

Create a user

On the same page, enter a username and a strong password, then save the user. Share these with the people who need access.
Test it: open the folder’s address in a private (incognito) window. Your browser should ask for the username and password.

Remove access or protection

  • Remove one person: open the folder in Directory Privacy again and delete their user.
  • Unlock the folder: untick Password protect this directory and save.
Don’t protect public_html itself unless you mean to lock your whole website. Visitors, and search engines, won’t be able to see any of it.
The login box sends the password in a way that’s only safe over https://. Make sure your site uses SSL. See Force HTTPS.
Still stuck? Open a ticket with your domain name and the folder you want to protect.