> For the complete documentation index, see [llms.txt](https://docs.hostinger.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hostinger.com/websites/password-protected-directories.md).

# Password-Protected Directories

Require a username and password to access specific directories. Visitors see a browser prompt before they can view the content.

Common uses:

* Development or staging sites
* Admin or internal areas
* Client preview pages

## Set up in hPanel

1. Open your website dashboard.
2. Go to **Advanced** → **Password Protect Directories**.
3. Pick or enter the **directory** to protect.
4. Set a **username** and **password**.
5. Click **Protect**.

Visitors now see an auth prompt on that directory.

## Manage protected directories

All protected directories are listed in the panel. You can:

* Add more users to a directory
* Change a user's password
* Remove protection

## Via `.htaccess`

### 1. Create `.htpasswd`

Store usernames and hashed passwords. Put it **outside** `public_html` (e.g., `/home/username/.htpasswd`).

```bash
htpasswd -c /home/username/.htpasswd yourusername
```

### 2. Add `.htaccess`

In the directory you want to protect:

```apacheconf
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/username/.htpasswd
Require valid-user
```

Replace `/home/username/.htpasswd` with your actual path.

## Remove protection

* **In hPanel:** Go to **Advanced** → **Password Protect Directories** and remove the directory from the list.
* **Via `.htaccess`:** Remove the `AuthType`, `AuthName`, `AuthUserFile`, and `Require` lines.

***

*Last updated: July 22, 2026*
