Jump to content

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


Recommended Posts

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.