![]() |
|
|
|
|
|
Password protecting a directory
You can use a .htaccess file and password database to secure your entire site, or individual directories. 1) Create a file called ".htaccess" in the directory you want protected. This file should contain something like this: AuthName "My private stuff" AuthType Basic AuthUserFile /home/user/htpasswd.stuff require valid-user If you were securing a directory called "pages," for example, you would replace "stuff" with "pages" and place the file in your "pages" directory. Change "user" in "/home/user/htpasswd.stuff" to your username. For example: /home/ben/htpasswd.whatever Never place the password file anywhere in your public_html directory. If you do, people will be able to download the password file. 2) Now you can add users to the password database. If your file was called /home/user/htpasswd.stuff, you would type: htpasswd -c /home/user/htpasswd.stuff newusernameReplace "user" and "stuff" as before. Replace "newusername" with a username to create. It will then ask you for a password, and the user is created. To add another user, leave out the "-c" parameter, for example: htpasswd /home/user/htpasswd.stuff newusernameThe "-c" parameter tells htpasswd to create a new file, erasing your previous database. More documentation can be found at ApacheWeek. Return All text and original images copyright (C) 1998, 1999, 2005 Llama Communications call (877) 552-6220 |
|