Password-protect a folder

directory privacy, password, htpasswd, staging, security · 0 found this helpful

A folder password asks visitors for a username and password before they can open a folder. Use it to hide a site under construction, or files meant for one client.

Important: This protects against casual visitors. It is not a substitute for application security, and files in the folder remain unprotected if someone knows a direct link that bypasses the folder, such as through another domain.

Protect a folder

  1. Open Account → Hosting → your site → Files. Under Folder and server rules, click Manage.
  2. Under Folder settings, type the folder, such as public_html/clients, and click Show.
  3. Find Password protection.
  4. Enter a Name shown at sign-in, for example Client area.
  5. Click Turn on.
  6. Add a Username and a strong Password, then click Add user.
Folder settings on the Folder and server rules page

Visit the folder in a private browser window. You should see a sign-in box.

Add or remove a user

Return to the folder's settings in Files. Add a user, or click Remove next to one to delete it. Click Turn off to remove protection.

Protecting WordPress staging

If you set up a staging site, protect its folder here so search engines and visitors can't find the draft. Also keep search engines out of the staging copy from WordPress, under Settings → Reading.

If something goes wrong

  • Prompt keeps reappearing: the password is wrong, or you changed it. Reset the user.
  • WordPress rejects the login prompt on admin-ajax: some plugins call a file inside the protected folder. Protect a subfolder instead of the site root.
  • Everything shows a 500 error: the generated .htaccess conflicts with your other rules. Remove protection, then reapply. See .htaccess basics.

Was this helpful?

Still stuck? Ask us and we'll walk you through it.