Technology3 min read

How to Password Protect any Web Page or Directory on cPanel

Abhishek Ahlawat

By Abhishek Ahlawat โ€” Recently

Founder of StudyTonight and a MERN fullstack developer. Writes about JavaScript, web development, Linux, and tech.

Summarize this article using AI

In my previous post, I wrote about how to use .htaccess and .htpasswd files for enabling authentication (password protection) on any webpage or on all the web pages of your website. Well, as always, there are many other ways of doing this including a very simple one using cPanel.

cPanel provides a lot of features which we generally ignore in our daily use. I stumbled upon this feature when I had to restrict access to our testing environment. It's super easy to implement and you can even use it for enabling authentication for your admin panel, restricted web pages, or maybe the development/testing server.

Follow the steps to password protect any webpage or web directory or the entire website using cPanel:

1. Login to your cPanel account and click on the option Directory Privacy in Files section.

password protect directory with cpanel

2. Choose the folder/directory you want to password protect. If you want to enable protection for the entire website then select the public_html directory or if you want to enable password protection on any particular web page or directory then navigate to it and then click on the name of the directory.

password protect directory with cpanel

3. Check the "Password Protect this directory" checkbox and enter a username and password and click on Save. You can also use the password generator to generate a strong password.

password protect directory with cpanel

That's it we are done.

Now whenever someone will try to access the protected directory on a web browser they will have to provide a username and password to access the web pages.

Hope this article help you and if you face any challenge, feel free to comment down below.


Spotted something outdated or wrong?

Liked this? See more StudyTonight posts in Google results.

Add StudyTonight as a preferred source
Next questLIVE OPSStep 2 / 3

Practice real incidents in the browser

System Design Ops โ€” put out fires, ship fixes, and stack XP. Reading done. Time to play.

Play System Design
  • +XP

    Every sim

  • Incidents

    Live ops

  • Ranks

    Climb up

Read next