MohitC
MohitC

Reputation: 4811

How to inherit directory directives in apache conf file

My google-fu always fails me with getting help on apache.

For example, I have following directives:

<Directory /path/toVhostRoot> 
Options none 
Satisfy all 
Order allow,deny 
</Directory>

and I make a subdir with just:

<Directory /path/toVhostRoot/subdir> 
Allow from all 
</Directory> 

Now I want-

Options none 
Satisfy all 
Order allow,deny

Should be inherited by the subdir, but this is not happening. Any way to achieve this?

This is just an example to demonstrate what I want, these are not actual directives on which I want to do this.

Upvotes: 1

Views: 1514

Answers (2)

LZeta
LZeta

Reputation: 1

You can apply shell-style wildcard characters to the path in your Directory directive, so that

<Directory "/path/toVhostRoot*">
 ... common directives group
</Directory>

Such a way "... common directives" group will be applyed not only to root dir, but also to it's subdirs.

If more complex matching roule is needed, then it is possible to use <DirectoryMatch> directives instead which is compatible with regular expression (regex) sintax.

As far I can see wildcard and regex in <Directory> and <DirectoryMatch> are sopported by apache starting from 1.3 revision.

Check your web server manual to verify such option.

Upvotes: 0

MohitC
MohitC

Reputation: 4811

Practicing my google-fu for another day helped me fix the problem. Answering so that I get blessings from anyone who comes across this ever.

What I did is simply add the common directives into a separate directives.conf

Options none 
Satisfy all 
Order allow,deny

And now Include this in whichever directory directive I want it.

<Directory /path/toVhostRoot> 
  Include /path/to/directives.conf
</Directory>

<Directory /path/toVhostRoot/subdir>
  Include /path/to/directives.conf
  Allow from all 
</Directory>

Upvotes: 2

Related Questions