Skip to main content

cPanel: Password-protect a directory

Use Directory Privacy in cPanel to require a username and password before visitors can access a specific website directory. This is useful for test websites or content that is not yet ready for publication.

Who is this guide for?

This guide applies exclusively to customers whose hosting is managed on the new Webland platform (WHMCS) and whose hosting plan includes cPanel.

Essential Hosting without cPanel: This guide does not apply to your hosting.

Previous platform using System Configurator or Domain Manager: Sign in at classic.webland.ch. The steps below do not apply to that platform.


Important information

  • Password protection applies to access through your website (HTTP/HTTPS). Access through FTP, SFTP or the cPanel File Manager is unaffected.

  • Subdirectories inherit the password protection of their parent directory.

  • Protection can also restrict automated access by applications or external services. Choose the directory carefully.

  • You create separate login credentials for the protected directory. These are independent of your client area, cPanel and website login credentials.


Requirements

Before you begin, make sure you:

  • Are signed in to the client area on the new Webland platform.

  • Have access to your cPanel hosting service and Directory Privacy.

  • Know which existing directory you want to protect.


Step 1: Sign in to cPanel

  1. Find your hosting service in the active services overview in the client area.

  2. Click “Log in to cPanel”.

You will be signed in to cPanel automatically.


Step 2: Open Directory Privacy

Open the “Files” section in cPanel and click “Directory Privacy”.

You will see the directory structure of your hosting account.


Step 3: Select the directory

  1. Navigate to the directory you want to protect. Click a directory name to view its subdirectories.

  2. Click “Edit” next to the directory you want to protect.

Check that you have selected the correct directory before continuing.


Step 4: Enable password protection

  1. Select “Password protect this directory”.

  2. Enter a label for the protected area, such as Test website. This label does not change the directory’s actual name.

  3. Click “Save”.

  4. After the confirmation appears, click “Go Back”.

Password protection is now enabled. Next, create a user who can access the directory.


Step 5: Create a user

  1. Enter a username in the “Create User” section.

  2. Enter and confirm a strong password. Alternatively, use “Password Generator”.

  3. Click “Save”.

Store the credentials securely and share them only with people who should have access.


Step 6: Test password protection

  1. Open a private browser window.

  2. Visit the protected directory’s website address using HTTPS.

  3. When prompted, enter the credentials you just created.

After signing in successfully, you can access the protected content.


Disable password protection

  1. Open “Directory Privacy” in cPanel again.

  2. Click “Edit” next to the relevant directory.

  3. Clear the “Password protect this directory” checkbox.

  4. Click “Save”.

If a parent directory is still protected, its password protection may continue to apply to this directory.


Troubleshooting

My login credentials are not accepted

Use the user you created in Directory Privacy for this directory. Check the spelling and capitalisation.

No password prompt appears

Check that you saved the protection settings and that the website address points to the protected directory. Test in a new private browser window, as your browser may have remembered a previous login.

My website no longer works properly after enabling protection

Check whether required files or subdirectories are also protected. If necessary, temporarily disable protection and check whether the website works again.

Did this answer your question?