Jump to content


Photo

Q: Httpd.conf With Multiple Directories At The Same Level ?


  • Please log in to reply
No replies to this topic

#1 foo

foo

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 25 November 2012 - 12:25 PM

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 by foo, 25 November 2012 - 12:27 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com