How to password protect a directory

This tutorial covers how to password protect a directory within a website. Users browsing to that directory in a web browser will be prompted for a password prior to being able to view it's contents.

It assumes you have first [logged into Virtualmin](/documentation/tutorial/how-to-log-in).

0. Choose the domain you would like to add the protected directory account to. You can do that by selecting the domain name from the drop-down box on the top-left.

0. Click Services.

0. Click Protected Directories.

0. Choose whether the password protection should be for the entire website, a sub-directory, or part of cgi-bin.

If you choose a sub-directory or cgi-bin, enter the directory name you are protecting, relative to public_html or cgi-bin. For example, if the password protection should be on http://example.com/secret/, then enter secret into the textbox.

0. Enter the Authentication Realm. This is the text that the user will see when being prompted for a password.

0. Click Create

0. Now go into 'Edit Users' -> USERNAME -> Other User Permissions

0. In the selectbox next to `Allow access to web directories`, select the directories this user should have permission to access.