foo Posted November 25, 2012 Share Posted November 25, 2012 (edited) Originally I was using a .htaccess file in each directory that I wanted to password protect from list view. Then I read in the Apache documents that the server would take a performance hit because even one .htaccess file in a directory will cause the server to look in all directories for an .htaccess file. So I learned access to the directory listing could be controlled via the httpd.conf file by editing it as I've done below for each directory that I want to password protect. My question is; Do I have to list every directory that I want to password protect in it's own listing<Directory /> ? Or can I use a relative link somehow to have them all follow the same rule all at once? The folder at the 3rd level is named differently for each directory path from htdocs.But the folder at the 4th level is named identically the same within each subdirectory of that 3rd level. So the folder at the 4th level is always the same name. <Directory /> Options FollowSymLinks AllowOverride None # AllowOverride AuthConfig Order deny,allow Deny from all </Directory> #Will password protect the directory from list view <Directory C:/xampp/htdocs/1stLevelFolder/2ndLevelFolder/nonConstantDirNameEx4532_3rdLevel/4thLevelSameName> AllowOverride AuthConfig AuthType Basic AuthName "restricted area" AuthUserFile C:/xampp/htpasswdFile/.htpasswd require valid-user </Directory> #Will password protect the directory from list view <Directory C:/xampp/htdocs/1stLevelFolder/2ndLevelFolder/nonConstantDirNameEx6786_3rdLevel/4thLevelSameName> AllowOverride AuthConfig AuthType Basic AuthName "restricted area" AuthUserFile C:/xampp/htpasswdFile/.htpasswd require valid-user </Directory> I tried with just two slashes after 2ndLevelFolder: <Directory C:/xampp/htdocs/1stLevelFolder/2ndLevelFolder//4thLevelSameName> AllowOverride AuthConfig AuthType Basic AuthName "restricted area" AuthUserFile C:/xampp/htpasswdFile/.htpasswd require valid-user </Directory> I also tried an asterisk and a percent sign: <Directory C:/xampp/htdocs/1stLevelFolder/2ndLevelFolder/*/4thLevelSameName> AllowOverride AuthConfig AuthType Basic AuthName "restricted area" AuthUserFile C:/xampp/htpasswdFile/.htpasswd require valid-user </Directory> <Directory C:/xampp/htdocs/1stLevelFolder/2ndLevelFolder/%/4thLevelSameName> AllowOverride AuthConfig AuthType Basic AuthName "restricted area" AuthUserFile C:/xampp/htpasswdFile/.htpasswd require valid-user </Directory> Is there a way to do such a thing? Thank you in advance! Edited November 25, 2012 by foo Quote Link to comment https://forums.phpfreaks.com/topic/271149-q-httpdconf-with-multiple-directories-at-the-same-level/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.