> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hostcloud.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Password-protect a folder on your website

> Ask visitors for a username and password before they can open part of your site, using Directory Privacy in cPanel.

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.

> [!NOTE]
>
> 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](https://kb.hostcloud.in/cpanel/log-in-to-cpanel.md), 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.

> [!WARNING]
>
> 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.

> [!TIP]
>
> The login box sends the password in a way that's only safe over `https://`. Make sure your site uses SSL. See [Force HTTPS](https://kb.hostcloud.in/ssl/force-https.md).

Still stuck? [Open a ticket](https://kb.hostcloud.in/support/open-a-ticket.md) with your domain name and the folder you want to protect.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.