Password-protect a folder
Restrict access to a folder of your site from Plesk: create the protection, add users, test access and fix common errors.
On this page
Your values
Enter them once and the commands in this guide update.
Plesk can ask for a username and password before displaying a folder of your site. This is useful for a private area, a staging site or documents reserved for a few people.
The protection applies to the chosen folder and to everything it contains.
Prerequisites
- Access to Plesk, see Connect to Plesk interface.
- A site accessible over HTTPS, see Enable a Let's Encrypt certificate.
Step 1: protect the folder
- In Plesk, go to Websites & Domains and locate your domain.
- Open Password-Protected Directories.
- Click Add Protected Directory.
- Enter the folder path, relative to the site root. For example,
/privatecorresponds tohttps://your-domain.com/private/. - If you wish, enter the title to show to visitors.
- Click OK.
The / path protects the entire site.
Step 2: add a user
Until a user is added, nobody can open the folder.
- In Password-Protected Directories, click the folder.
- Click Add a User.
- Enter a username and a long, unique password.
- Click OK.
This access applies only to this folder. It is separate from your Plesk account and your FTP accounts. For several folders, add the user to each of them.
Step 3: check the protection
Open the folder's address in a private browsing window. The browser must ask for a username and password.
From a terminal, first check that access is refused without credentials:
curl -I https://your-domain.com/private/The expected response is 401. Then test with your account; curl will ask for the password:
curl -I -u YOUR_USER https://your-domain.com/private/You should get 200. A 403 or 404 response may simply mean that the folder has no home page: in that case, test the address of a specific file.
Manage the protection
All these actions are done in Websites & Domains > Password-Protected Directories.
| Action | Procedure |
|---|---|
| Change the title | Click the folder, then Directory Settings |
| Change a password | Click the folder, then the user |
| Remove a user | Click the folder, select the user, then click Remove |
| Remove the protection | Select the folder, then click Remove Protection |
Removing the protection makes the folder accessible to everyone again, unless the site restricts it in some other way.
WordPress sites
To hide a WordPress site under construction, WP Toolkit offers its Password Protection option on the site card. See Install WordPress and manage it with WP Toolkit.
Troubleshooting
| Symptom | Likely cause | Solution |
|---|---|---|
| The password is always refused | Wrong user, or user added to another folder | Check the folder's list and set the password again |
| Nobody can get in | No user is associated with the folder | Add at least one |
| The folder remains public | The path entered is different, or you are seeing a cached page | Compare the exact path and test with curl |
| The browser no longer asks for the password | It keeps the credentials during the session | Close the browser or use private browsing |
| Password prompt loop | The address changes along the way, for example from HTTP to HTTPS or from www to non-www, and each variant asks for access again |
Open the final https:// address directly |
| Images or files return a 404 error in the protected folder | Static files are processed by nginx | Contact support and give the address concerned |
| The Let's Encrypt certificate is no longer issued | The whole site is protected and the check of /.well-known/acme-challenge/ fails |
Remove the protection while the certificate is issued |
The WordPress site misbehaves after protecting /wp-admin |
AJAX calls are blocked | Remove this protection |