On my development machine osx-sierra / apache 2.4.10 (from brew) I have a restriction in a VirtualHost that allow access to /api/ without password, and all others pages need the password with this code:
<Location />
AuthType Basic
AuthName "Access"
AuthUserFile /Users/xxxxxx/www/public/.htpasswd
Require expr %{REQUEST_URI} =~ m#^/api/*#
Require valid-user
</Location>
When I try to do it on my production server with the same directives, Debian-jessie / apache 2.4.29 (from apt), it doesn't work, password is always ask (chrome/safari/wget), I tryed theses solutions :
1/
<Location />
AuthType Basic
AuthName "Access"
AuthUserFile /home/xxxxxx/www/public/.htpasswd
Require expr %{REQUEST_URI} =~ m#^/api/*#
Require valid-user
</Location>
2/
<Location />
AuthType Basic
AuthName "Access"
AuthUserFile /home/xxxxxx/www/public/.htpasswd
Require expr %{REQUEST_URI} =~ m#^/api/.*#
Require valid-user
</Location>
Any idea of why these differences ?
Thanks