Thu 1 Nov 2007
How can I password protect a directory in my Math Web space?
Posted by isaac under faq , infotech , webNo Comments
- You need to create two files.
- ~/WWW/protecteddir/.htaccess
- ~/.htpasswd
- An .htaccess file can be used to specify webserver settings at the directory or file level. Here is a sample .htaccess file:
- AuthName “Display name of protected area”
AuthType Basic
AuthUserFile /homes/ivetter/.htpasswd
#require user ivetter
require valid-user
- AuthName “Display name of protected area”
- Your .htaccess file points to a file of usernames and passwords, commonly named .htpasswd
- To create your .htpasswd directory and place a user in the file, run a command like this:
- /opt/csw/apache/bin/htpasswd -c ~/.htpasswd username
- You’ll be prompted for the password twice.
- Voila! You should now have a username and encrypted password in the ~/.htpasswd file.
- To add another username to your .htpasswd file, run this command:
- /opt/csw/bin/apache/htpasswd ~/.htpasswd username2
- To create your .htpasswd directory and place a user in the file, run a command like this:
- Please note that your .htpasswd file can go anywhere in your home directory, but must be readable (but never writable!) by the ‘nobody’ user (or the world). Additionally, it’s best to not place the ~/.httpasswd directory under your WWW folder.