Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
htpasswd file for different folder
Old 02-03-2011, 11:23 PM htpasswd file for different folder
Ultra Talker

Posts: 254
Trades: 0
i have created 1 htpasswd outside the public_html directory and placed this htpasswd
in a folder called in this htpasswd file i have mentioned username and password

i have .htaccess file in a folder called folder1 inside public_html directory that i want to password protect when someone accesses folder1 and a username and password prompt appears this is working fine

my question is if i want to similarly protect another folder inside public_html called folder2 and in the htpasswd that i already have if i add another username and password and if i have another .htaccess password inside folder2 that i want to protect how does apache know that for folder2 it should check the 2nd username and password i have mentioned in htpasswd file

or does apache look at all the usernames and passwords in htpasswd and when the username and password are correct apache gives access to the folders

is this how it works or do i have to create another htpasswd file for protecting folder2

in .htaccess inside folder1 the code is

AuthUserFile /home/username/.htpasswds/.htpasswd
AuthType Basic
AuthName "folder1"
Require valid-user


in .htaccess inside folder2 the code is

AuthUserFile /home/username/.htpasswds/.htpasswd
AuthType Basic
AuthName "folder2"
Require valid-user
sudhakararaog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-03-2011, 11:55 PM Re: htpasswd file for different folder
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
Apache looks first in the directory in which an asset lives, then up each directory level, for .htaccess files. Several .htaccess files can reference the same password file but you need to think through the user experience if you do this, or indeed the alternative of two different files. Access to folder2 would, in the latter case, cause the authentication popup for folder2 to be presented, followed if not already done in session by authentication for higher level - you'll have some confused and irritated visitors.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 02-04-2011, 12:01 AM Re: htpasswd file for different folder
Ultra Talker

Posts: 254
Trades: 0
so i were to create another .htpasswd file where should i place it currently i have .htpasswds folder in /home/username/.htpasswds

should i create a directory here ex folder2 and in the .htaccess inside folder2 should i write

AuthUserFile /home/username/.htpasswds/folder2/.htpasswd
AuthType Basic
AuthName "folder2"
Require valid-user
sudhakararaog is offline
Reply With Quote
View Public Profile
 
Old 02-04-2011, 01:51 AM Re: htpasswd file for different folder
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
Quote:
Originally Posted by sudhakararaog View Post
so i were to create another .htpasswd file where should i place it currently i have .htpasswds folder in /home/username/.htpasswds

should i create a directory here ex folder2 and in the .htaccess inside folder2 should i write

AuthUserFile /home/username/.htpasswds/folder2/.htpasswd
AuthType Basic
AuthName "folder2"
Require valid-user
The .htpasswd files can be anywhere as long as the path in .htaccess is correct. Having separate files is the better of the two solutions, yes..
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE

Last edited by PaulW; 02-04-2011 at 01:53 AM..
PaulW is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to htpasswd file for different folder
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33299 seconds with 12 queries