How to password-protect a folder
Adding a username and password prompt to any folder of your website with DirectAdmin’s password protected directories.
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
- Open Advanced Features › Password Protected Directories.
- Choose the folder to protect, for example
public_html/staging. - Enable protection and enter a prompt message, such as “Staging site”.
- 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.
- How to log in to DirectAdminWhere to find your DirectAdmin login address, how port 2222 works, and what to do when the login page won’t load.
- 403 Forbidden: how to fix itWhy the server refuses access with a 403 — missing index file, permissions, .htaccess rules or security blocks — and how to fix each one.
- “Permission denied” and files that won’t save or uploadFix uploads and saves failing with permission errors in WordPress, apps and FTP, without resorting to unsafe 777 permissions.
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.