How to Protect Directories with a Password in cPanel
In this tutorial we are going to discuss how to protect directories with a password using cPanel. Visit to your password protected directory must type username and password in order to see the contents of those directories.
It is very important to protect your WordPress admin (wp-admin) section. Though our wordpress hosting plan comes with many security features, But still we strongly recommend to protect your admin section even in the PHP or any other CMS based websites.
How Password Protection works?
We provide cPanel in all our linux shared web hosting. Kindly follow the below steps to protect your directory
A directory can be protected with a password from your Linux server with cPanel
cPanel >Security >Password Protect Directories.
Once the page is opened, you should see a list of the directories on your hosting account. You can open a directory in order to view its contents by clicking on the folder icon next to its name. Once you have browsed to the directory you are planning to protect, simply click on its name. This should open a new page on which you will be able to create an account that has access privileges to that directory once it has been password protected. Once you have created an account, simply check the box next to “Password Protect This Directory” and save your settings. Password protecting directories is recursive, meaning that once a directory is password protected all sub-directories in it will also be locked.
It is very crucial to understand how password protection actually works. When you opt to protect a directory with password using cPanel, cPanel then creates a rule in .htaccess file of your website. This rule states that the particular folder or directory is protected with a password and the visitor require to use the accurate username and password to see the files of that particular directory.
Steps to Protect a Directory with Password:
- Login to cPanel.
- Locate to the Files area and hit directory privacy.
- Choose the directory you wish to protect with a password and once you click any option it will redirect you to Set Permissions window.
- On this hit the check box labeled as Password protect the directory. Don’t forget to enter the name for the folder you are going to protect with a password.
- Click save button to save the process you have completed above.
- Now on this step you need to create a username and password to access the password protected directory.
- Hi save button to save the user that you have created.
- Now you have protected your directory using a password and when a user provide correct user name password can view the contents of your directory.
Removing password protection from a directory
You can also remove password from protected directory when you don’t wish to protect any directory with a password. In order to delete protection of a directory you don’t have to remove username and password that you created for protecting the directories. The username and password is reserved when you remove a password protection from your directory, it will just become inactive. If in future you want to re enable password protection for the directory, you can then use the same username and password.
Follow below instructions to remove password protection from a directory:
- Login to cPanel account.
- Go to the files area of cPanel, click Directory Privacy.
- Then hit the directory name for which you are going to remove password protection.
- Under the security settings, hit the checkbox labeled as clear the password protect this directory.
- And then click save.
If you need more information, feel free to contact our support team.