Knowledge Base
How to Password Protect a Directory in DirectAdmin
Adding Password Protection to Folders
Restrict access to specific folders with username/password authentication.
Method 1: Using DirectAdmin
- Log into DirectAdmin
- Click Password Protected Directories
- Click Protect a New Directory
- Navigate to and select the folder
- Enter a name for the protected area
- Add users who can access it
- Click Save
Method 2: Using .htaccess
Create a .htaccess file in the folder:
AuthType Basic AuthName "Restricted Area" AuthUserFile /home/username/.htpasswds/public_html/folder/passwd Require valid-user
Create the password file using DirectAdmin's built-in tool or via SSH.
Common Uses
- Protecting staging/development sites
- Restricting admin areas
- Creating member-only sections
- Protecting downloadable files
Removing Protection
- Go to Password Protected Directories
- Click on the protected directory
- Click Remove Protection