How to password-protect a folder

Adding a username and password prompt to any folder of your website with DirectAdmin’s password protected directories.

Guide2 min readLast updated
On this page
  1. Steps
  2. How it works
  3. Things to know
  4. Removing protection
  5. If it doesn’t work
  6. Common questions

A password-protected directory makes the browser ask for a username and password before showing anything inside a folder. It’s ideal for staging sites, private downloads and admin areas.

Steps

  1. Open Advanced Features › Password Protected Directories.
  2. Choose the folder to protect, for example public_html/staging.
  3. Enable protection and enter a prompt message, such as “Staging site”.
  4. Add a username and password, then save.

Visit the folder in a private browser window to confirm the prompt appears.

How it works

DirectAdmin adds rules to the folder’s .htaccess file and stores the usernames with hashed passwords in a separate file. The protection covers everything in the folder and its subfolders.

Things to know

  • Always use HTTPS for protected folders. Basic authentication sends credentials with each request, which is only safe over an encrypted connection. How to force HTTPS (redirect HTTP to HTTPS)
  • It’s not a replacement for application logins. Use it as an extra layer, for example in front of a staging copy of WordPress.
  • Search engines can’t index protected content, which is exactly what you want for staging sites.

Removing protection

Return to the same feature, select the folder and turn protection off.

Every Traxio account comes with the full DirectAdmin panel. If you’re still choosing a host, DirectAdmin hosting is £0.99 a month.

If it doesn’t work

These guides cover the most common problems, starting with what you can see. Or browse every fix for a common problem.

Common questions

How do I password-protect a folder on my website?

Use Advanced Features › Password Protected Directories in DirectAdmin: choose the folder, turn protection on and add a username and password. Visitors then get a browser login box before they can see anything in it.

This is the right tool for a staging area, a client preview or a private download folder. It is not a substitute for application-level logins — it protects files on the server, not individual pages inside a CMS.

Spotted something out of date or unclear? Tell us and we’ll fix it.

Keep going