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.

  1. 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.

  2. Click Services.

  3. Click Protected Directories.

  4. 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.

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

  6. Click Create

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

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