cPanel Security

How to Password Protect a Directory in cPanel

Lock down a staging area, admin folder, or private download page in a few clicks — no coding required.

Table of Contents

    Sometimes you need a folder on your site that only certain people can open — a staging version of a redesign, a private client area, or a downloads page you don't want indexed by Google. cPanel has a built-in tool for exactly this, and it takes about two minutes to set up.

    1. Log in to cPanel

    Log in to your cPanel account, usually at yourdomain.com/cpanel or via the link in your Vikalink welcome email.

    2. Open Directory Privacy

    In the Files section, click Directory Privacy (sometimes labelled "Directory Privacy" or "Password Protect Directories"). This opens a file browser starting at your account's root.

    3. Navigate to the folder you want to protect

    Click through your folder structure — usually inside public_html — until you reach the exact directory you want to lock. Click the folder name itself, not just the icon next to it.

    4. Enable password protection

    Tick "Password protect this directory", give the protected area a name (this is just a label shown in the login prompt, not a folder rename), and click Save.

    5. Create a user

    On the same page, scroll down to create a username and password for anyone who needs access. You can add more than one user later if several people need entry.

    6. Test it

    Visit the folder's URL in a private/incognito browser window. You should see a browser login prompt asking for the username and password you just created, before anything in the folder loads.

    Key takeaway: This method protects the whole folder at the web-server level, before WordPress or any script even runs — it's a good extra layer for a staging site, but it isn't a replacement for proper user accounts on a site your customers log into.

    Common issues

    If you get a 500 Internal Server Error after enabling protection, check that the .htaccess file in that folder wasn't already being used for something else, like WordPress permalinks — the two can conflict and may need combining. Browsers also cache credentials aggressively, so if you change the password later, fully close the browser (not just the tab) before testing again. To remove protection, go back into Directory Privacy, untick the password protection box, and save.