How to use htaccess to password protect files and directories?
To utilize htaccess dynamic password protection on a directory:
1. Telnet into your FTP account
telnet ftp.yourdomain.com
2. Create a passwd file. You can create a passwd file with the "htpasswd" utility on the server.
run htpasswd -c [filename] [user] 3. You will then be prompted for a password for the user. Type the password.
To add a new user to an existing password file, run the command:
htpasswd [passwd file] [user] Then you will be prompted for a password for "testpro2".
4. Create a .htaccess file. You can either create this file locally and ftp the file to the server, or you can edit the file directly on the server using the text editor pico: pico .htaccess
A standard .htaccess file contains the following:
AuthUserFile require valid-user
For example, if you want to protect a directory "testprotect" in your public_html directory, place the following .htaccess file in the testprotect directory. Be sure to include the full path including your home directory for the AuthUserFile. This assumes your document directory is located in /home/wcpdemo/testprotect, and your passwd file is named ".htpasswd" and is located in the members directory.
ex: htpasswd -c .htpasswd testpro
ex: htpasswd .htpasswd testpro2
AuthGroupFile
AuthName
AuthType Basic
AuthGroupFile /dev/null
?xml:namespace>