How to Password Protect a Directory in DirectAdmin

DirectAdmin allows you to protect folders on your website with a username and password.

This is useful for:

  • private client areas
  • staging websites
  • admin sections
  • download areas
  • restricted content

This guide explains how to password protect a directory in DirectAdmin.


What Is Directory Protection?

Directory protection restricts access to specific folders on your website.

Visitors must enter:

  • a username
  • a password

before accessing protected content.


Before You Start

Before protecting a folder, make sure:

  • You can log into DirectAdmin
  • The folder already exists
  • You know which folder you want to secure

If you have not logged in yet, please see:

  • How to Log Into DirectAdmin

Common Uses for Password Protection

Password-protected folders are commonly used for:

  • development websites
  • private downloads
  • staff-only areas
  • testing environments
  • client-only content

How to Password Protect a Directory

Step 1 — Log Into DirectAdmin

Open your browser and visit:  https://cp.yourdomain.co.za   (Replace yourdomain.co.za with your own domain name)

Enter your hosting username and password.


Step 2 — Open Password Protected Directories

From the DirectAdmin dashboard:

Click:  Advanced Features

Then click:  Password Protected Directories


Step 3 — Select the Domain

Choose the domain containing the folder you want to protect.

Example:  yourdomain.co.za (Replace yourdomain.co.za with your own domain name)

 

Step 4 — Browse to the Folder

Navigate to the directory you want to protect using the > next to the directories.

If you haven't already use file manager to create a directory in the public_html folder to use.

Examples: /public_html/private

or

/public_html/dev

Give it a realm name
 

Step 5 — Enable Password Protection

Select the folder and enable password protection.

Depending on your DirectAdmin version, this may appear as:

  • Protect

Step 6 — Create a Username and Password

Enter:

  • a username
  • a strong password

for accessing the protected folder.

Example:

Username: clientaccess
Password: enter a secure password

Click: Add User
 

Step 7 — Save the Settings

Click:  Update Realm

The folder is now protected.


Testing the Protected Directory

Visit the protected folder in your browser.

Example: https://yourdomain.co.za/private

You should now see a login prompt requesting:

  • username
  • password

Important Notes

Password Protection Uses Browser Authentication

Visitors will see a browser login popup instead of a normal website login page.


SSL Is Recommended

We strongly recommend enabling HTTPS on protected folders to secure usernames and passwords.


Multiple Users May Be Supported

Some DirectAdmin versions allow multiple usernames for the same protected folder.


Troubleshooting

Password Prompt Does Not Appear

Check:

  • folder selected correctly
  • protection enabled
  • browser cache
  • .htaccess functionality

Username or Password Rejected

Verify:

  • spelling
  • uppercase/lowercase letters
  • saved credentials

Try recreating the user if necessary.


Protected Folder Returns Error 500

This may be caused by:

  • corrupted .htaccess
  • incorrect permissions
  • conflicting website rules

Contact HostworX support if needed.


Browser Keeps Asking for Password

Possible causes include:

  • incorrect credentials
  • browser cache
  • conflicting security settings

Try another browser or private browsing mode.


Helpful Tips

Protect Development Websites

Password protection is useful for:

  • test websites
  • redesign projects
  • staging environments

before public launch.


Remove Old Protected Accounts

Delete unused usernames regularly for better security.


Use Strong Passwords

Avoid:

  • simple passwords
  • reused passwords
  • common words

Security Tips

  • Always use HTTPS
  • Use strong passwords
  • Remove unused protected users
  • Keep website software updated
  • Avoid exposing development areas publicly
  • directadmin ssl management, directory protection, website security
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Change Your DirectAdmin Password

Changing your DirectAdmin password regularly helps improve the security of your hosting account...

How to Check If Your SSL Certificate Is Working

After enabling an SSL certificate, you should check that your website loads securely using HTTPS....

How to Enable a Free SSL Certificate Using Let’s Encrypt in DirectAdmin

SSL certificates help secure your website and protect information sent between your website and...

How to Enable Hotlink Protection in DirectAdmin

Hotlink protection helps prevent other websites from directly using your images, files, or media...

How to Force HTTPS Redirects in DirectAdmin

After installing an SSL certificate, visitors may still be able to access your website using the...