Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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

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
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
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 /another/directory>
  Include /etc/httpd/conf.d/accesslist

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


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.