Require directive in .htaccess prevents directories from being shown
I have the following directory hierarchy
-root_folder .htaccess -sub_folder .htaccess
The content of the .htaccess file in sub_folder:
AuthType Basic AuthName "webdav" AuthUserFile /var/www/test/passwd.dav Require user test
root_folder contains the following
Satisfy any Order deny,allow Deny from all Allow from env=ALLOWED SetEnvIfNoCase Request_URI "^/+webdav/root_folder/?$" ALLOWED
Note, please, that i am using
It is set up in
/etc/apache2/conf.d/webdav. The file contains the following:
Alias /webdav /home/user/projects/test/public <Location /webdav/> Order Allow,Deny Allow from #list of ips here DAV On PassengerEnabled off LimitXMLRequestBody 0 Options Indexes FollowSymLinks </Location>
The problem is that when i try to access
localhost/webdav/root_folder/ folder using browser the
sub_folder is not displayed.
But when i remove the
Require user some_user directive the
sub_folder is shown in the list. If i try to enter
Require user directive is enabled i’m asked to enter login and password and everything is ok if i enter correct credentials.
Is it possible to list everything within directory and at the same time use
require user directives in .htaccess files inside sub_folders to control access to them?
In your root_folder (I believe that is your
$DOCUMENT_ROOT) create .htaccess file with following content:
SetEnvIfNoCase Request_URI "^/*$" ALLOWED Satisfy any Order deny,allow Deny from all Allow from env=ALLOWED
root_folder is not $DOCUMENT_ROOT then use:
SetEnvIfNoCase Request_URI "^/+root_folder/?$" ALLOWED
as the first line.
Answered By – anubhava