Creating Private Directories In Your Math Web Space

You can create a password protected, private directory in your Math department web space. To do this, simply follow the steps below.

  1. Create the directory you wish to protect.
    Log into login.math.wisc.edu and create a directory for the documents you wish to protect. For example:
    cd ~/public/html/
    mkdir private
    chmod 0755 private
    cd private
    echo "Hello World" > index.html
    chmod 0644 index.html
    

    At this point, you should be able to access the private directory through your web space at http://www.math.wisc.edu/. For example, if your user name is 'spock', your new private directory would be accessible at http://www.math.wisc.edu/~spock/private/.

  2. Create a .htpasswd file.
    Create a password file with the names of users you want to have access to your private space. For example, if you wanted to give user 'spock' access to the private directory, type the command below and then enter a password at the prompt.
    htpasswd -c .htpasswd spock
    

    The user names you add do not have to be real user names on the Math department computers. To give additional users access, you would again use the htpasswd command. For example, to give user 'kirk' access, type the command below and enter a password at the prompt.
    htpasswd .htpasswd kirk
    


  3. Create a .htaccess file
    Create a file named .htaccess in your private directory that contains text similar to the following :
    AuthUserFile /staff/spock/public/html/private/.htpasswd
    AuthType Basic
    AuthName "Private  space"
    
    <LIMIT GET POST>
    require valid-user kirk
    </LIMIT>
    

    Note: You must change the first line in the text above to contain the full path to the .htpasswd file you created in the previous step. Change kirk to the name of the valid user. You can have several require valid-user lines each with a different user name. Remember to give these files the proper permissions:
    chmod 644 .htaccess .htpasswd


  4. Test your private web space
    Point your browser to the private directory you created. A dialog box asking for a user name and password should appear. Note that if you previously pointed your browser to this directory, you may have to press the refresh key in your browser to make the dialog box appear. Enter one of the user names and passwords that you entered in the previous step. This should allow you to see the page again. All documents in this directory and all documents in sub-directories will be password protected.


Copyright (©) 2008 by the Board of Regents of the University of Wisconsin-Madison