• Wednesday, February 25, 2026

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

  1. Log into DirectAdmin
  2. Click Password Protected Directories
  3. Click Protect a New Directory
  4. Navigate to and select the folder
  5. Enter a name for the protected area
  6. Add users who can access it
  7. 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

  1. Go to Password Protected Directories
  2. Click on the protected directory
  3. Click Remove Protection