How to Password Protect a Directory in cPanel
Sometimes you need a folder — a staging copy of a site, an internal tool, a set of client files — visible only to people with a password, without building a full login system. cPanel’s Directory Privacy feature does exactly this at the web server level.
Setting it up
- Go to Files > Directory Privacy.
- Navigate to and select the folder you want to protect.
- Tick “Password protect this directory” and give it a label (shown in the login prompt).
- Save, then scroll down to create a username and password for someone who should have access — repeat to add more users.
What visitors see
Anyone browsing to that folder’s URL gets a plain browser-native username/password prompt (HTTP Basic Authentication) before anything in the folder loads — including any web pages inside it, so this protects the whole directory, not just a single page.
Good use cases
- A staging/development copy of a live site, kept out of search engines and casual visitors.
- A shared folder of files for a specific client, without setting up individual accounts.
- An internal admin tool that doesn’t have its own authentication built in.
What it isn’t good for
This is a blunt, all-or-nothing lock on an entire folder — it isn’t a substitute for a real login system if you need different users to see different content, or for anything requiring detailed access logs and permission levels. It’s also visible as a login prompt, not a hidden folder — the URL itself isn’t secret, only what’s inside it once you try to load it.
Removing protection later
Return to Directory Privacy, select the folder, and untick “Password protect this directory” — the folder becomes publicly accessible again immediately.
Our support team is here 24/7
Open a ticket or send us a message -- a real person replies to every request.
Contact support