Re: User authentification

From: Date: Thu, 10 Aug 2000 15:00:19 +0000
Subject: Re: User authentification
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-1725@lists.php.net to get a copy of this message
> I need to have users input a password to acces some parts of the > site. Does anybody know how to do that, knowing I don't want to use > mod_php if unstable : the OS is just as unstable I don't want to > have to reboot it twice an hour (pretty long to boot), it's a > production server... I thought of .htaccess files, but don't know > how it works, didn't find on Apache's site :[ > Would anybody know a URL where I can get help on .htaccess ?? Funny, I thought I had mailed this to you before, but I'm still getting the grasp on some things... here it goes again (regarding a previous post from you). I modified it a little from my original reply, since it was missing a detail: --------------From previous post > While I'm at it, how can I ask for a logon with php running as a > CGI? Don't seem to be able to use .htaccess under Win32 ? (can't > install a Linbox here at work...) Since you're using apache, and using .htaccess seems to be good enough for you, I have it working on my Win95 box this way (should be about the same for NT): 1. httpd.conf, insert in your <Directory "c:/apache/htdocs"> (or whatever your docroot is): AllowOverride All //Check other options AuthName "MyInternet" //For the auth dialog AuthType Basic //Or any type you wish AuthUserFile d:/apache/bin/users.txt //Your place of choice require valid-user //Or specific users... 2. httpd.conf, change the following directives: AccessFileName htaccess.txt //Or name of your choice <Files htaccess.txt> Order allow,deny Deny from all </Files> It seems that Win32 doesn't like filenames beggining with dot, that's why I used a ".txt" 3. htaccess.txt for any given directory: AuthName "My Directory" AuthType Basic AuthUserFile d:/apache/bin/users.txt AuthGroupFile d:/apache/bin/groups.txt require user ann bob require group mygroup order deny,allow deny from none allow from all 4. Use the htpasswd.exe command line utility in \apache\bin to create users in your users.txt file (the utility encripts the password and creates the record in the users file with the correct format). 5. groups.txt file has a very simple format: group1: user11 user12 user13 group2: user21 user22 user23 (...etc) This exact configuration is working on Win95/Apache 1.3.12, with very satisfactory results. I got this from the Apache manual FAQ: G. Authentication and access restriction, 2.How do I set up Apache to require a username and password to access certain documents? It takes you to an apacheweek article: http://www.apacheweek.com/features/userauth Hope it helps. Gonzalo.

« previous php.windows (#1725) next »