📄 mod_access.html.en
字号:
<span class="indent">
Order Deny,Allow<br />
Deny from all<br />
Allow from env=let_me_in<br />
</span>
</Directory>
</code></p></div>
<p>In this case, browsers with a user-agent string beginning
with <code>KnockKnock/2.0</code> will be allowed access, and all
others will be denied.</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="Deny" id="Deny">Deny</a> <a name="deny" id="deny">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls which hosts are denied access to the
server</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Deny from all|<var>host</var>|env=<var>env-variable</var>
[<var>host</var>|env=<var>env-variable</var>] ...</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_access</td></tr>
</table>
<p>This directive allows access to the server to be restricted
based on hostname, IP address, or environment variables. The
arguments for the <code class="directive">Deny</code> directive are
identical to the arguments for the <code class="directive"><a href="#allow">Allow</a></code> directive.</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="Order" id="Order">Order</a> <a name="order" id="order">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls the default access state and the order in which
<code class="directive">Allow</code> and <code class="directive">Deny</code> are
evaluated.</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Order <var>ordering</var></code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>Order Deny,Allow</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_access</td></tr>
</table>
<p>The <code class="directive">Order</code> directive, along with the
<code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives, controls a
three-pass access control system. The first pass processes either
all <code class="directive"><a href="#allow">Allow</a></code> or all
<code class="directive"><a href="#deny">Deny</a></code> directives, as
specified by the <code class="directive">Order</code> directive. The second
pass parses the rest of the directives (<code class="directive"><a href="#deny">Deny</a></code> or <code class="directive"><a href="#allow">Allow</a></code>). The third pass applies to
all requests which do not match either of the first two.</p>
<p>Note that all <code class="directive"><a href="#allow">Allow</a></code>
and <code class="directive"><a href="#deny">Deny</a></code> directives are
processed, unlike a typical firewall, where only the first match is
used. The last match is effective (also unlike a typical firewall).
Additionally, the order in which lines appear in the configuration
files is not significant -- all <code class="directive"><a href="#allow">Allow</a></code> lines are processed as one
group, all <code class="directive"><a href="#deny">Deny</a></code> lines are
considered as another, and the default state is considered by
itself.</p>
<p><em>Ordering</em> is one of:</p>
<dl>
<dt><code>Allow,Deny</code></dt>
<dd>First, all <code class="directive"><a href="#allow">Allow</a></code>
directives are evaluated; at least one must match, or the request
is rejected. Next, all <code class="directive"><a href="#deny">Deny</a></code> directives are evaluated. If
any matches, the request is rejected. Last, any requests which do
not match an <code class="directive"><a href="#allow">Allow</a></code> or a
<code class="directive"><a href="#deny">Deny</a></code> directive are
denied by default.</dd>
<dt><code>Deny,Allow</code></dt>
<dd>First, all <code class="directive"><a href="#deny">Deny</a></code>
directives are evaluated; if any match, the request is denied
<strong>unless</strong> it also matches an <code class="directive"><a href="#allow">Allow</a></code> directive. Any requests
which do not match any <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directives are
permitted.</dd>
<dt><code>Mutual-failure</code></dt>
<dd>This order has the same effect as <code>Order
Allow,Deny</code> and is deprecated in its favor.</dd>
</dl>
<p>Keywords may only be separated by a comma; <em>no whitespace</em>
is allowed between them.</p>
<table class="bordered">
<tr>
<th>Match</th>
<th>Allow,Deny result</th>
<th>Deny,Allow result</th>
</tr><tr>
<th>Match Allow only</th>
<td>Request allowed</td>
<td>Request allowed</td>
</tr><tr>
<th>Match Deny only</th>
<td>Request denied</td>
<td>Request denied</td>
</tr><tr>
<th>No match</th>
<td>Default to second directive: Denied</td>
<td>Default to second directive: Allowed</td>
</tr><tr>
<th>Match both Allow & Deny</th>
<td>Final match controls: Denied</td>
<td>Final match controls: Allowed</td>
</tr>
</table>
<p>In the following example, all hosts in the apache.org domain
are allowed access; all other hosts are denied access.</p>
<div class="example"><p><code>
Order Deny,Allow<br />
Deny from all<br />
Allow from apache.org
</code></p></div>
<p>In the next example, all hosts in the apache.org domain are
allowed access, except for the hosts which are in the foo.apache.org
subdomain, who are denied access. All hosts not in the apache.org
domain are denied access because the default state is to <code class="directive"><a href="#deny">Deny</a></code> access to the server.</p>
<div class="example"><p><code>
Order Allow,Deny<br />
Allow from apache.org<br />
Deny from foo.apache.org
</code></p></div>
<p>On the other hand, if the <code class="directive">Order</code> in the
last example is changed to <code>Deny,Allow</code>, all hosts will
be allowed access. This happens because, regardless of the actual
ordering of the directives in the configuration file, the
<code>Allow from apache.org</code> will be evaluated last and will
override the <code>Deny from foo.apache.org</code>. All hosts not in
the <code>apache.org</code> domain will also be allowed access
because the default state is <code class="directive"><a href="#allow">Allow</a></code>.</p>
<p>The presence of an <code class="directive">Order</code> directive can
affect access to a part of the server even in the absence of
accompanying <code class="directive"><a href="#allow">Allow</a></code> and
<code class="directive"><a href="#deny">Deny</a></code> directives because
of its effect on the default access state. For example,</p>
<div class="example"><p><code>
<Directory /www><br />
<span class="indent">
Order Allow,Deny<br />
</span>
</Directory>
</code></p></div>
<p>will <code class="directive"><a href="#deny">Deny</a></code> all access
to the <code>/www</code> directory because the default access state
is set to <code class="directive"><a href="#deny">Deny</a></code>.</p>
<p>The <code class="directive">Order</code> directive controls the order of
access directive processing only within each phase of the server's
configuration processing. This implies, for example, that an
<code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directive occurring in a
<code class="directive"><a href="../mod/core.html#location"><Location></a></code> section
will always be evaluated after an <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directive occurring in a
<code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>
section or <code>.htaccess</code> file, regardless of the setting of
the <code class="directive">Order</code> directive. For details on the
merging of configuration sections, see the documentation on <a href="../sections.html">How Directory, Location and Files sections
work</a>.</p>
</div>
</div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/mod/mod_access.html" title="English"> en </a> |
<a href="../ja/mod/mod_access.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
</div><div id="footer">
<p class="apache">Copyright 2007 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -