You can limit access to files on your site by requiring users to type a password to gain access. When users attempt to access a file in a protected directory, the Web server displays a login window. Users with access privileges can enter their user names and passwords to access the directory. Users without access privileges cannot gain access and will see an error page. An example of a directory that should be protected is the /awstats directory – you may not wish everyone to see that access statistics for your website.
How to protect directories
The Web server manages access to password-protected directories on your site based on groups. Before you can protect a directory, you need to create at least one group, and add at least one user to that group.
1. Create a group
- In your control panel, click the Shortcuts tab on the Home page.
- In the Web Server Management area, click Directory Protection Groups.
- Click Add Group.
- In the Enter Group name field, enter a name for the group you are creating. Names should be made up of alphanumeric characters, dash, underscore or period.
- Click Add Group.
2. Add User(s) to the Group.
- Click Manage Users in the shortcut bar.
- Click Add User.
- Type in the username and password. In the Belongs to Group(s) field, specify the group the user should be added to.
Note: You can select multiple groups by pressing and holding down the Ctrl key (PC) or Cmd key (mac) while clicking the group names.
- Click Add User
3. Protect the directory
- In the shortcuts bar, click Protect Directories. A list of the directories on your site, identified as either unprotected or protected , is displayed.
- From the directory list, locate the directory you want to protect, then in the Actions column, click . To protect the web stats directory, you would choose /var/www/html/awstats
- In the AuthName field, enter a descriptive name for the directory you want to protect. When users attempt to access files, this name is displayed in the login window. Maximum length 20 characters.
- In the Add to Group(s) field, specify the groups(s) that are allowed to access this directory.
Note: You can select or clear multiple directories by pressing and holding down the Ctrl key (PC) or Cmd key (mac) while clicking the directory names.
- Click Protect. The directory is now protected. Users are now required to enter user names and passwords before accessing information in the directory.
When you remove password-protection from a directory on your site, all access limitations are removed from the directory. This makes it possible for users to access files in the directory without entering user names and passwords.
To remove protection from a directory:
- Click the Shortcuts tab on the Home page.
- In the shortcuts, click Web Server Management area, then Directory Protection. A list of the directories on your site, identified as either unprotected or protected , is displayed.
- From the directory list, locate the directory from which you want to remove protection, and in the Actions column, click . The protection is now removed from the directory.
Important: You can protect directories only; you cannot protect individual files. If you want to protect a single file, either place that file in an existing protected directory, or create a directory specifically for that file, then protect the directory.