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
  • What exactly is the problem you're seeing ? What error messages do you see, what did you expect, are there any relevant log messages ?
    – user9517
    Feb 16 '14 at 6:42
  • Expected behavior: No login prompt upon accessing the subdirectory. Actual: Login prompt.
    – Daniel B
    Feb 16 '14 at 14:30

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
$ 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

  • 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 '14 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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