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'm currently upgrading to Apache 2.4.

What puzzles me right now is how to create a public subdirectory using .htaccess only. The outer directory is protected by AuthType Basic

Previously, the directory contained the following .htaccess:

Satisfy Any
Allow from all

I'm at a loss at how to reproduce this in Apache 2.4. I tried any combination of the following, without luck:

AuthType None
Require all granted
AuthMerging Or
share|improve this question
    
What exactly is the problem you're seeing ? What error messages do you see, what did you expect, are there any relevant log messages ? –  Iain Feb 16 at 6:42
    
Expected behavior: No login prompt upon accessing the subdirectory. Actual: Login prompt. –  Daniel B Feb 16 at 14:30

1 Answer 1

up vote 0 down vote accepted

I tested this here and it works for me. Check that the .htaccess file is being read for each directory; perhaps enable authentication on the subdirectory temporarily with a different AuthName so you can verify.

Here's my setup, in case you find it useful. The directory with auth enabled is authtest; its subdirectory noauth has authentication disabled.

$ /usr/sbin/apache2 -v
Server version: Apache/2.4.7 (Debian)
Server built:   Jan  2 2014 01:47:52
$ cat /etc/apache2/conf-enabled/allow-htaccess-authtest.conf 
<Directory /var/www/html/authtest>
    AllowOverride AuthConfig
</Directory>
$ cat /var/www/html/authtest/.htaccess 
AuthType Basic
AuthName "ahoy hoy"
AuthUserFile /home/fission/htpasswd
Require valid-user
$ cat /var/www/html/authtest/noauth/.htaccess 
AuthType None
Require all granted

That syntax was pulled directly from the Apache docs for mod_authn_core

share|improve this answer
    
Thanks, this indeed does work. In the meantime, I checked everything again and found I had the authentication defined twice, in .htaccess and also in a <Location "/"> block in the virtual host config. According to this page, <Location> takes precedence over (almost) everything. Which is why I was unable to override it using .htaccess. –  Daniel B Feb 16 at 16:06

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.