Click to See Complete Forum and Search --> : I need a simple .htaccess script


blastbum
02-16-2005, 11:49 PM
Hi,

First of all I would like to point out that I'm new to .htaccess.

I need a simple .htaccess script that asks for a username and password when you go to a site (eg; www.whatever.com).

I would like it to allow different sets of usernames and passwords that allow access to different pages.

As an example, if you put in the username and password:

Username: whatever
Password: whatever49

It would then grant access to the "/whatever.html" page.

Thank you very much for your help.

Blastbum :D

TheBearMay
02-17-2005, 12:13 PM
.htaccess isn't a script language, however, if you create a .htpasswd file and give it the path you can use it to protect directories.

Sample .htaccess

AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

AuthUserFile /home/lvl1/lvl2/userHome/public_html/PwdReq/.htpasswd
AuthGroupFile /home/lvl1/lvl2/userHome/public_html/PwdReq/.htgroup
AuthType Basic
AuthName "Authorization Name"

require group myGroup

Sample .htpasswd:

User_1:jVj24eedPLxeU
User_2:BBhUSyKac2HHQ
User_3:0aGbOojU2hVVc
User_4:aewSz31DGP4jA

Sample .htgroup:

Admin: User_2 User_4

myGroup: User_1 User_2 User_4

TheBearMay
02-17-2005, 12:16 PM
Some resources you may want to look at:

http://httpd.apache.org/docs/howto/htaccess.html
http://www.freewebmasterhelp.com/tutorials/htaccess/
http://www.javascriptkit.com/howto/htaccess.shtml