The Directory Privacy page lets you password-protect a directory. You can use this option to give specific users access to a part of your website. The user will need to enter their username and password to access the page.
Creating a password-protected folder is not very difficult but the process is not very intuitive. Let’s look at an example…
On the Directory Privacy page you see the same directories we saw when we looked at cPanel’s file manager.
Note: if you want to password-protect your entire website then you can simply click on the public_html link.
In the below example we have navigated to the public_html directory. Inside the directory is a folder called private-files. This is the folder that we are going to protect. To do so, simply click on the name:
Image: selecting the ‘private-files’ directory
Protecting a directory is a two-step process:
At this point we have password-protected the directory. However, we haven’t yet created a user name and password for the directory. As things stand nobody is able to access the directory.
The next step is therefore creating a user that is allowed to access the directory. In the below example we are creating the user Fruitcake:
Image: creating a user that may access the directory.
And that’s it, anyone who now tries to access example.net/private-files will be prompted for a user name and password. If they get the user name or password wrong they will see an error 401 (“Access Denied”).
Image: The password prompt.
As you can see in the above image, the name we entered for the directory (“Private files”) is shown in the dialogue window. You can use the name to give the user a hint. For instance, instead of “Private files” we could have named the directory “your favourite lunch”. In that case your browser would show the message: ‘The site says: “your favourite lunch”.
You can create more than one authorised user. Users you add will be listed at the bottom of the page, with the option to delete the user.
Removing the password protection is again a two-step process: