Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have three dirs in /var/www/html, one of them has .htacces with following:

Order Allow, Deny
Allow from all
AuthUserFile /var/www/.htpasswd
AuthGroupFile /dev/null
AuthName 'lalalal'
AuthType Basic

Require user lala

When sending request to that dir, server returns 403 instead of 401.
When requesting other dirs, server returns 200.
What is also interesting is that when checking server-info page, there is not a single line refering to protected dir, nor its siblings.

Edit

Error log shows:
'Permission denied: /var/www/html/drugi/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable'
.htaccess file has 644 permissions.

share|improve this question
2  
Does your error log (/var/log/httpd/error_log) have any relevant messages and if so what are they? –  Iain Jul 28 '12 at 21:49
    
Yes, thank you! There's 'permission denied' for the .htaccess in the dir in question, which is odd, concerning it has 644 permissions... –  cbaby Jul 28 '12 at 22:06
    
Show us the exact error message. –  Iain Jul 28 '12 at 22:07
    
Permission denied: /var/www/html/asdf/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable –  cbaby Jul 28 '12 at 22:10
1  
Paste what you get for ls -alZ /var/www/html/drugi. Or whatever the name of the directory in question is. –  Michael Hampton Jul 28 '12 at 22:15
show 1 more comment

2 Answers

up vote 2 down vote accepted
Order Allow, Deny
Allow from all

These are not required if you're using HTTP authentication and you can get rid of them. (And Order breaks if there is whitespace after the comma.)

BTW, it's a good idea to keep your htpasswd file outside the web documents directory.

Since you've updated your question with additional information, I would say that you should also check the permissions in the directory with ls -alZ to check both the Unix permissions and the SELinux contexts.

share|improve this answer
    
I've added them after first encountering the issue, thinking that there is a directive somewhere overriding this .htaccess file. My web root is actually /var/www/html and this is just testing, but thanks for the heads-up anyway. –  cbaby Jul 28 '12 at 21:53
add comment

The 403 suggests that there is a permissions error. Check that the apache user has permission to read the .htaccess file and that is has traverse permission on the drugi directory tree, so that would be r-x for other (if it isn't owned by apache)or r-x for owner/group if it is owned by apache or it's group.

share|improve this answer
    
Both directory and containing htaccess have apache:apache as owner. And I've tried setting 755 permissions to both of them to no avail. –  cbaby Jul 28 '12 at 22:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.