Setting up access protection on a website directory
First you need to decide if you want to restrict access with:
- a username and password that you create
- by hostname or network address
- a Computer Science Department account
Keep in mind that this restricts web-based access only. If someone has a CS account they can view any directory on the server.
Creating an .htaccess
file
Any of these protection methods requires an .htaccess
file.
The .htaccess
file goes in the directory you want to restrict access to. For example, /fs/www/path/to/webdir/.htaccess.
User-based authentication
- To protect your directory with a username and password that you create, place the following content in your
.htaccess
-
Create an
.htpasswd
file with the usernames and hashed passwords that will be able to access the directory. The easiest way to do this is with thehtpasswd
utility. If the.htpasswd
file doesn’t exist, use the-c
flag to create it.htpasswd [-c] /fs/www/path/to/webdir/.htpasswd <username>
Host-based authentication
You can allow access from a combination of UMD or Department hosts. Include one of these or the other - if you need to limit access to more specific parts of campus, contact us for assistance:
Computer Science Department Account
UMD CAS Account
This authentication method should work for all students and may include alumni. The UMD CAS Service is under the control of DIT, not CS staff, and may change behavior without notice.
Our current default CAS server is UMD, so no other directives are needed. You can specify the CAS server explicitly.
Allow specific users
You may replace Require valid-user
with Require user username1 username2 username3....usernameN
to only allow the named users to access the resource.
Multiple Authentication Methods
For user or host authentication
Include the sections above and modify the <Require*>
section
For user and host authentication
Include the sections above and modify the <Require*>
section