Maintained by ic@ucsc.edu |
Restricting access to your course web siteThis document explains how to give your pages password protection or restrict access by IP addresses or domains. Note: This document assumes that you are able to access the webserver via Secure Shell (SSH) or FTP, and are familiar with basic UNIX commands such as editing a file, or uploading one via FTP. If you would like assistance, please contact fitc@ucsc.edu. Access restriction is done at the directory level; you cannot restrict
access to a single file (except by putting the file in a directory and
restricting access to that directory). To restrict access to a directory,
you need to create a file called
Restricting by domain:Insert the lines on the right into your
You could also specify IP domains by number, or even specify a specific IP address. To make it accessible from more than one domain, list the domains in "allow from x" statements one right after the other.
<Limit GET POST>
order deny,allow deny from all allow from XXX.YYY.ZZZ </Limit> Example
<Limit GET POST>
order deny,allow deny from all allow from ucsc.edu allow from 163.28.49.200 </Limit> Restricting by password: Insert the lines on the right into your
Example Change the variables
AuthName DIR_NAME
AuthType Basic AuthUserFile HTPASSWD_DIRECTORY/.htpasswd <Limit GET POST> require user NAME </Limit> Example
AuthName "Linguistics 101"
AuthType Basic AuthUserFile /home/people/slug/.htpasswd <Limit GET POST> require user bananaslug </Limit> Now you need to create a Here you will need to log in using your shell account in order to run the following command from the unix prompt.
/home/local/apache/bin/htpasswd -c /HTPASSWD_DIRECTORY/.htpasswd NAME
For example, the
/home/local/apache/bin/htpasswd -c /home/people/slug/.htpasswd bananaslug
After running that command, you will be prompted to enter a password twice. If you're having problems:
Make sure that the global read bit is set on the
chmod ugo+r PROTECTED_DIR/.htaccess
chmod ugo+r HTPASSWD_DIRECTORY/.htpasswd For example, in the "Linguistics 101" example, the commands would be as follows, assuming that the name of the protected directory is
chmod ugo+r /home/people/slug/public_html/ling101/.htaccess
chmod ugo+r /home/people/slug/.htpasswd Please use the form below to tell us what you think of this page. USCS Faculty Instructional Technology Center |