Apache:更改允许和拒绝需要

时间:2016-11-05 20:44:58

标签: apache require httpd.conf

我需要更改下面的内容以改为使用 Require 指令,但我不确定我是否正确执行此操作。我还处于学习阶段的早期阶段,并且不确定一切是如何运作的。

<Directory /usr/local/apache/htdocs/mywebsite>
Order Allow, Deny
Deny from all
Allow from atlanticferries.com
</Directory>

我的重写版本是:

<Directory /usr/local/apache/htdocs/mywebsite>
<RequireAll> 
Require host atlanticferries.com
</RequireAll>
</Directory>

我还想过使用RequireNone来编写这样的代码:

<Directory /usr/local/apache/htdocs/mywebsite>
<RequireNone> 
Require not host atlanticferries.com
</RequireNone>
</Directory>

如果是用Require写的,这是怎么做的?谢谢!

1 个答案:

答案 0 :(得分:0)

RequireAny和Requirenone标签适用于涉及更多Require指令的更复杂情况。

您需要的是:

<Directory /usr/local/apache/htdocs/mywebsite>
    Require host atlanticferries.com
</Directory>

或拒绝:

<Directory /usr/local/apache/htdocs/mywebsite>
    Require not host atlanticferries.com
</Directory>

或到10.20.0.0/16的ip范围(仅举例)。

<Directory /usr/local/apache/htdocs/mywebsite>
    Require ip 10.20
</Directory>

更改单个Require语句的目的是简化操作,而不是使它们更复杂。

有关更详细的说明和示例,请查看需要文档Require documentation