📞 +254 104 666 000 ✉️ support@autohost.co.ke 📍 Rovies Business Centre – Ukunda / Diani

Knowledge Base · Hosting Setup Guides

How to Password-Protect a Folder on Your Website

Want clients to preview a new design before launch, or keep reports and documents away from the public and search engines? Directory Privacy adds a login box in front of any folder on your website in about two minutes.

⏱ 4 min read · Updated 27 October 2026  ·  ← All guides

Time needed3 minutes

When a folder is protected, anyone opening a page inside it sees a browser login box. Only the usernames you create can get in. It protects everything inside the folder, including sub-folders, images and PDFs.

What visitors see when they open a protected folder. The label you choose appears in the box (1).
Figure 1 What visitors see when they open a protected folder. The label you choose appears in the box (1).

Good uses

Folder Why protect it
/staging or staging.yourbusiness.co.ke Client previews before launch; keeps unfinished pages out of Google
/reports, /documents Price lists, internal reports and board papers
/admin of a custom-built system A second lock in front of the real login
/downloads for paying customers Simple gated downloads

Step 1: Open Directory Privacy

In cPanel, go to Files → Directory Privacy. You will see your home folder’s contents.

Step 2: Find the folder

Click folder names to open them (for example public_html → staging). When you see the folder you want to protect in the list, click Edit next to it.

Navigate to the folder (1) and click Edit next to it (2). Click a folder's name to open it; click Edit to protect it.
Figure 2 Navigate to the folder (1) and click Edit next to it (2). Click a folder's name to open it; click Edit to protect it.

Step 3: Turn on protection

  1. Tick Password protect this directory.
  2. In Enter a name for the protected directory, type a label visitors will see, e.g. Staging site — client preview.
  3. Click Save.

Step 4: Create a user

Scroll down to Create User:

  1. Username — e.g. client or the person’s name.
  2. New Password — click Password Generator for a strong one, and copy it.
  3. Click Save.

Create one user per person so you can remove access individually later.

Tick Password protect (1), add a label (2), then create a user (3) and Save (4).
Figure 3 Tick Password protect (1), add a label (2), then create a user (3) and Save (4).

Step 5: Test in a private window

Open https://yourbusiness.co.ke/staging in an incognito/private window. The login box should appear. Enter the username and password — the page should load.

Tip

Send the link, username and password to your client in separate messages (for example link by email, password by WhatsApp).

Removing access

  • One person: in Directory Privacy → the folder → Authorized Users, click Delete next to their name.
  • Everyone: untick Password protect this directory and click Save.

Protecting a WordPress staging site

If the protected folder contains WordPress, the login box appears before the WordPress login — that is fine. Two things to know:

  • Do not protect your main site’s wp-admin folder this way unless you know how to allow admin-ajax.php; some plugins stop working. Use a security plugin instead — see Secure your WordPress website.
  • WP Toolkit staging copies can be password-protected from WordPress Management → your staging site → Password protection, which does the same thing.

Troubleshooting

Problem Cause Fix
Login box keeps reappearing Wrong username or password, or a typo when creating Delete the user and create it again
Whole website now asks for a password You protected public_html itself Untick protection on public_html and protect only the sub-folder
500 error after enabling A conflicting rule in the folder’s .htaccess Rename that .htaccess temporarily, or ask support
Password box does not appear Browser has saved the login Test in a private window or another browser

Frequently asked questions

Is this secure enough for sensitive files?
It is a good barrier and is encrypted when your site uses HTTPS. For highly confidential data (medical, payroll), use a proper document system with individual accounts and audit logs.

Will Google index protected pages?
No — search engines cannot get past the login box.

Tags:securitydirectory privacystaginghtaccess

Figures are simplified illustrations. Your screen may look slightly different depending on your theme and the version of cPanel or the app you use.

Still need help?

Our Kenyan support team is on WhatsApp — real people, not bots. Mon–Sat, 8am–10pm EAT. Tickets are open 24/7.

Related guides

All Articles

Scroll to Top