Discussion Locked

Apache htaccess/Authentication

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm trying to restrict access to certain folders under httpd. I created /etc/httpd/conf/passwd file and added user1 & user2. In httpd.conf, I added:

AllowOverride AuthConfig
AuthName "Apache Web Server"
AuthType Basic
AuthUserFile /etc/httpd/conf/passwd
require valid-user

This works fine, but I want only user1 to have access to /var/www/private. So I created a .htaccess file in private and put require user1. However user2 also can access this folder. Any ideas?
Thanks

4 replies

by mckaytech

Probably the best way to go would be to create another directory configuration for /var/www/private and put 'require user1' rather than 'require valid-user'.

I have a feeling that there is something other than AuthConfig that you need to add to your AllowOverride to make it work right without doing this, but I can't put my finger on it. If I find it, I'll re-post.

paul

by rouse

Sorry so long to get back. I changed the AuthType in each to be Basic and everything seems to work. Thanks again

by rouse

I'm not using the .htaccess files, but put the following in the httpd.conf:

AllowOverride AuthConfig
AuthName "Apache Web Server"
AuthType Basic
AuthUserFile /etc/httpd/conf/passwd
require valid-user

AllowOverride AuthConfig
AuthName "Private"
AuthType Basic
AuthUserFile /etc/httpd/conf/private
require user1

I am using 2 different AuthUserFile, however both users belong to the 'web' group which own the www folder (0755) and below, but I'd like only user1 to gain access to 'private' with a web browser.
Do I need to restructure?
Where I'm ultimatly heading is to allow restricted accesses based on login names.
Thanks for looking at this.

This discussion is closed to new replies.