Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

On Apache2, I have a VirtualHost with a number of <Directory> directives/sections containing multiple access control statements

i.e.

<Directory /foo>
    Order Deny,Allow
    Deny from all
    Allow from ...
    Allow from ...
    ...
</Directory>
...

Is there a way to specify the access control at a higher level (above <Directory>)? Or should I be using macros?

Thanks in advance!

share|improve this question
1  
you can just specify a <Directory ...> directive for the highest level folder appropriate, even if it's your web-root (i.e. set it in the 'default' conf file for localhost) –  Chris Aug 23 '12 at 16:06
    
But what if the <Directory> directives have no common parent folder? –  wodow Aug 23 '12 at 16:10
    
like I said you can apply the appropriate configuration / directives directly on your 'localhost' (i.e. domain/web-root) -- what OS are you running, if Linux then prob /var/www is your web-root, you can use a .htaccess file or edit your 'default' vhost config for localhost! –  Chris Aug 23 '12 at 16:14

1 Answer 1

up vote 1 down vote accepted

If I understand your question, you're looking for a way to apply a set of allow/deny restrictions to a set of directories that may not share a common parent.

You can place all your allow/deny directives into a separate file (call it, say, /etc/httpd/conf.d/accesslist, or whatever makes sense in your distribution), and then using the Include directory to include those rules where appropriate:

<Directory /some/directory>
  Include /etc/httpd/conf.d/accesslist
</Directory>

<Directory /another/directory>
  Include /etc/httpd/conf.d/accesslist
</Directory>

But if your directories all share a common configuration, you can use something like mod_macro to create a reusable template with variable substitution.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.