|
This article applies to the following HKUST Web servers: iHome Home Teaching |
The .htaccess file shown below limits access to the
webpage to users in the given password file.
AuthUserFile /home/<"username">/public_html/.htpasswd AuthName ByPassword AuthType Basic require user usera userb userc ... |
Assuming your account is cc_test and you would like limit the access to
john, peter and ben, your .htaccess file will looks like
AuthUserFile /home/cc_test/public_html/.htpasswd AuthName ByPassword AuthType Basic require user john peter benThe
.htpasswdcontains list of users and UNIX encrypted passwords pair in following format:
usera:QDFpR/cbBgJ8Q
userb:HQxv/8uQHe.Qk
userc:BASZJcujRHRyk
...We provide a simple web interface here to generate the encrypted passwd with cleartext one. If you are using UNIX timesharing system, the
.htpasswdfile can be created by htpasswd program. For example:
htpasswd -c .htpasswd useraThe program will then ask for
usera's password and add it to the newly created password file. When you want to add another useruserb, leave out the "-c" switch:
htpasswd .htpasswd userbGroup file
.htgroupis just a text file with lines consists of a group name followed by a list of users. For example:
friends: usera userb webmaster: usera userb usercAdd you can add the directive
AuthGroupFilein.htaccessas below to limit access to specific group of users.
AuthUserFile /home/<"username">/public_html/.htpasswd AuthGroupFile /home/<"username">/public_html/.htgroup AuthName ByPassword AuthType Basic require group friends
Configuration directives
Access Directives
AuthTypetype- Must be
BasicAuthNamename- The symbolic name of this access file. It shows up when a user is prompted for a password. Specify whatever you think is appropriate.
AuthUserFilefile- Specifies the absolute path of the user's password file.
AuthGroupFilefile- Specifies the absolute path of the user's group access file.
require valid-user- Allow all users in the
AuthUserFilefile access upon providing a valid password.require useruser1 user2 ...- Specify which users (separated by spaces) in the
AuthUserFilefile are allowed access upon providing a valid password.require groupgroup1 group2 ...- Specify which groups of users in the
AuthGroupFilefile are allowed access upon providing a valid password.