Security

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Security

Post by oldtimer »

I would like to password protect a folder. I am not sure where to ask this so I thought I would ask the fine people here. I use Debian running apache. I heard from someone that with the pear package you can do this. I dont use the htaaccess.
User avatar
BigE
Site Admin
Posts: 139
Joined: Fri Apr 19, 2002 9:49 am
Location: Missouri, USA
Contact:

Post by BigE »

Well... you can use PHP's User Auth thats built in, but that won't protect a whole directory, just the files you put it on. php.net/features.http-auth for more information on that. The only other way that I'm aware of is using .htaccess. Hope that helps.
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

Yeah I pw protect pages right now but I want to do the whole directory as I want to protect more than just the pages.

How do you set up the htaccess? I have never understood that part either.
User avatar
BigE
Site Admin
Posts: 139
Joined: Fri Apr 19, 2002 9:49 am
Location: Missouri, USA
Contact:

Post by BigE »

Just setup a .htaccess file in the folder you want to protect that looks something like this

Code: Select all

AuthType Basic
AuthName "My Sites Secureness"
AuthUserFile /path/to/.htpasswd
Require valid-user
For the .htpasswd file, just use Apache's built in program to make .htpasswd files from the command prompt. If you want to learn more about it, search http://www.apache.org for more infomation on .htpasswd. The program used is infact called htpasswd so if you search for that, it should give you a couple of pages that should work fairly well. Hope that helps.
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

Thank you. With your help and a little reading I now have the htaccess working.
Post Reply