htaccess Setup

Let's get started. I'll use the user called 'generic.' Make sure to put your own info in when required. Copy and paste the commands.

You use htaccess to password protect your webpages. It works best on a directory-by-directory level. For example, files in /home/generic/public_html/private/ show up at http://www.rupture.net/~generic/private/. If you don't want the world to be able to look at the directory called 'private,' you can use htaccess to protect it.

The first thing to do is create a .htaccess file.


generic@froody:~/> cd public_html/private
generic@froody:~/public_html/private> pico .htaccess

AuthType Basic
AuthName ByPassword
AuthUserFile /home/generic/webpass
require valid-user

generic@froody:~/public_html/private> 

Make it say the above. Use whatever editor you like. This file, .htaccess, acts as a control file. The webserver says, "A-ha! There's something special about this directory. It is protected, and requires a valid user from the password file '/home/generic/webpass'."

So now you need to create that password file, /home/generic/webpass.


generic@froody:~/public_html/private> cd
generic@froody:~> /web/bin/htpasswd
Usage:
        htpasswd [-cmdps] passwordfile username
        htpasswd -b[cmdps] passwordfile username password

        htpasswd -n[mdps] username
        htpasswd -nb[mdps] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -m  Force MD5 encryption of the password.
 -d  Force CRYPT encryption of the password (default).
 -p  Do not encrypt the password (plaintext).
 -s  Force SHA encryption of the password.
 -b  Use the password from the command line rather than prompting for
it.
On Windows, TPF and NetWare systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
generic@froody:~> 
generic@froody:~> /web/bin/htpasswd -c webpass bobotheclown
New password:
Re-type new password:
Adding password for user bobotheclown
generic@froody:~> 
generic@froody:~> /web/bin/htpasswd webpass kokotheclown
New password:
Re-type new password:
Adding password for user kokotheclown
generic@froody:~>

That's all there is to it. The password for user 'bobotheclown' is 'lalalala'. Feel free to try it out. Always remember to keep your webpass file in your home directory. That is, not in your public_html directory. When you first create the webpass file, you need to use htpasswd -c. But to add more users, you can omit the -c flag. Play around with it, it's fun.

As always, if you have specific questions, email the admin.

<admin*rupture.net>

File /htaccess/setup.shtml
was last updated : 05:25 PM 11/03/04