如何在apache conf文件中继承目录指令

时间:2016-04-06 16:50:48

标签: apache

我的google-fu总是让我无法获得apache的帮助。

例如,我有以下指令:

class Person(name: String = "noname", age:Int = -1){}

object ReflectionTester{
 def main(args: Array[String]) {
  val m = ru.runtimeMirror(getClass.getClassLoader)
  val classTest = m.staticClass("Person")
  val theType = classTest.toType

  //class mirror
  val cm = m.reflectClass(classTest)
  val ctor = theType.decl(ru.termNames.CONSTRUCTOR).asMethod
 }
}

我只用:

创建一个子目录
<Directory /path/toVhostRoot> 
Options none 
Satisfy all 
Order allow,deny 
</Directory>

现在我想要 -

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

应该由subdir继承,但这不会发生。有没有办法实现这个目标?

这只是一个展示我想要的例子,这些不是我想要做的实际指令。

2 个答案:

答案 0 :(得分:1)

在另一天练习我的google-fu帮助我解决了这个问题。回答,以便我得到任何遇到过这种情况的人的祝福。

我所做的只是将通用指令添加到单独的directives.conf

Options none 
Satisfy all 
Order allow,deny

现在将其包含在我想要的任何目录指令中。

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

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

答案 1 :(得分:0)

您可以将Shell样式的通配符应用于Directory指令中的路径,这样

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

以这种方式"... common directives"组将不仅应用于根目录,还应用于子目录。

如果需要更复杂的匹配规则,则可以改用<DirectoryMatch>指令,该指令与正则表达式(regex)sintax兼容。

到目前为止,我可以看到wildcardregex中的<Directory><DirectoryMatch>是由1.3 revision开始的apap注入的。

检查您的web server manual,以验证该选项。