How to Password Protect a Folder from Web Visitors

As you may be aware, data that you place within the public_html folder and any of its subfolders is normally accessible by any web visitor. That’s how the public is able to access your websites.

Sometimes, however, you might want to password-protect a particular folder, so that only certain visitors are allowed access to data within that folder using their web browsers.

Setting Up Directory Privacy

You can use the Directory Privacy feature in your hosting control panel (cPanel) to set this up.

  1. Sign in to your HostM hosting account’s cPanel.

    Your cPanel access details are listed on the hosting account’s Info page in the Client Lounge.

  2. Click the Directory Privacy icon.

  3. Click the icon (not text) of the folder into which you’d like to nagivate.

  4. Click the text (not icon) of the folder which you’d like to protect.

  5. Select the Password protect this directory option and enter a name for the protected directory. This could be something simple like 'Secure Area' to tell people why it’s password protected.

    Click the Save button when you’re done.

  6. Under the 'Create User' section, create the desired login credentials, then click the Save button.

You’re all set! The specified folder should now be password protected when someone tries to access it using their web browser.

Be careful not to accidentally protect folders containing data that is meant to be shown to the general public! Doing so could cause lost traffic and search engine rankings due to visitors and search engines being unable to access sections of your website.