How to Password Protect folders via cPanel

Updated on Sep 7, 2018

In this tutorial we will show you how to password protect your directories and restrict web access. Password protection can be useful when you would like to have certain resources accessible only by a certain group of people.

To password protect a directory login your account's cPanel and refer to the Security section in your cPanel where you will locate the Directory Privacy icon.

password protection

Select the Web Root directory during the Directory selection and click on the Go button to proceed.

select directory

You will be redirected to the Directory Privacy page where you can see the directory tree of your hosting account. To expand a folder click on the yellow folder icon. If you would like to password protect the directory, click on the directory name.

For the purpose of this tutorial we will password protect the public_html directory. Password protecting the public_html folder will protect any file or folder on your hosting account and the public access will be denied, only people having the correct login details will be able to open your website and access files hosted on your account.

Password protecting your public_html directory is a good idea if your website is still under development and you do not want to have it accessible by visitors or search engine bots.

To activate the password protection on the directory click on the check box "Password protect this directory" and input a short message that will be displayed just above the login box when someone access this folder.

When you are ready click on the Save icon to apply your settings. Now you have your directory password protected and it is not accessible for your visitors. To give access to someone to access this folder via their web browser you will need to add a user and password pair. To do so, please click on the Go Back button to return to the Password Protected Directories page.

Scroll down to the Create User section and input the desired username and password that will be able to access the password protected resource.

create user

When you are ready click on the Add/Modify authorized user button.

Now if you try to open your password protected directory via your browser you will be prompted with a login form to input your authorized user.

Input your username and password to test your settings. You should be able to login with the authorized user you have just created. You can always add additional or remove existing users as well as change the login credentials via your cPanel → Directory Privacy section.

To remove a password protection of a directory, simply uncheck the check box in the Security Settings section and save your configuration.

This will make your folder publicly accessible.

On this page...

    cPanel Hosting

    • Free Domain Transfer
    • 24/7 Technical Support
    • Fast SSD Storage
    • Hack-free Protection
    • Free Script Installation
    • Free Website Transfer
    • Free Cloudflare CDN
    • Immediate Activation
    View More