Docs Home Return to Homepage
Get Started Login

How to Password Protect a Folder on Your Website in cPanel

Last updated Changelog

On this page

Directory Privacy puts a password on a folder of your website. Anyone who opens a page in that folder sees a login box and needs a username and password to get in. It’s a quick way to hide a staging site, a members area or files for one client. In this example we’ll protect yourdomain.com/members.

Steps

  1. Log in to cPanel. In the Files section, click Directory Privacy.

    The cPanel Files section with Directory Privacy highlighted

  2. Click public_html to open your website’s folder. Find the folder you want to protect and click Edit next to it.

    The public_html folder list with the members folder and its Edit button highlighted

  3. Tick Password protect this directory. Type a name for the protected area: visitors see it in the login box. Click Save, then Go Back.

    Password protect this directory ticked, the name “Members area” and Save highlighted

  4. Under Create User, choose a Username, then enter a New Password twice (or use Password Generator). Click Save, then Go Back.

    Create User with the username member, both password boxes and Save highlighted

  5. The user is listed under Authorized Users. Add more users the same way if more than one person needs to get in.

    Authorized Users listing member

In our test, https://cpanel.cranedemo.com/members/ showed a login box straight away and only opened with the right username and password.

Note: The username and password are only for this folder. They’re not an email or cPanel login, so you can give them out without sharing anything else.

Troubleshooting

Problem What to do
I want to change a user’s password Under Create User, enter the same username with the new password and click Save.
I want to remove someone’s access Select them under Authorized Users and click Delete User.
I want to remove the password completely Click Edit next to the folder, untick Password protect this directory and click Save.
The login box keeps coming back Check you’re typing the username exactly as you created it. Passwords are case-sensitive.

Snagged on something? Contact support and we’ll get you sorted.

Snagged on something?

Our sysadmins answer tickets around the clock.