📄 mod_access.html.en
字号:
href="mod_setenvif.html#setenvif">SetEnvIf</a>.</p> <hr /> <h2><a id="deny" name="deny">Deny</a> <a id="denyfromenv" name="denyfromenv">directive</a></h2> <p> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> Deny from all|<em>host</em>|env=<em>env-variable</em> [<em>host</em>|env=<em>env-variable</em>] ...<br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> directory, .htaccess<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> Limit<br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Base<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_access</p> <p>This directive allows access to the server to be restricted based on hostname, IP address, or environment variables. The arguments for the <code>Deny</code> directive are identical to the arguments for the <a href="#allow">Allow</a> directive.</p> <p>See also <a href="#allow">Allow</a>, <a href="#order">Order</a> and <a href="mod_setenvif.html#setenvif">SetEnvIf</a>.</p> <hr /> <h2><a id="order" name="order">Order directive</a></h2> <p> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> Order <em>ordering</em><br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> <code>Order Deny,Allow</code><br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> directory, .htaccess<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> Limit<br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Base<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_access</p> <p>The <code>Order</code> directive, along with the <code>Allow</code> and <code>Deny</code> directives, controls a three-pass access control system. The first pass processes either all <code>Allow</code> or all <code>Deny</code> directives, as specified by the <code>Order</code> directive. The second pass parses the rest of the directives (<code>Deny</code> or <code>Allow</code>). The third pass applies to all requests which do not match either of the first two.</p> <p>Note that all <code>Allow</code> and <code>Deny</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>Allow</code> lines are processed as one group, all <code>Deny</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>Allow</code> directives are evaluated; at least one must match, or the request is rejected. Next, all <code>Deny</code> directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an <code>Allow</code> or a <code>Deny</code> directive are denied by default.</dd> <dt><code>Deny,Allow</code></dt> <dd>First, all <code>Deny</code> directives are evaluated; if any match, the request is denied <strong>unless</strong> it also matches an <code>Allow</code> directive. Any requests which do not match any <code>Allow</code> or <code>Deny</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; no whitespace is allowed between them.</p> <table border="1"> <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> <blockquote> <code>Order Deny,Allow<br /> Deny from all<br /> Allow from apache.org<br /> </code> </blockquote> <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>Deny</code> access to the server.</p> <blockquote> <code>Order Allow,Deny<br /> Allow from apache.org<br /> Deny from foo.apache.org<br /> </code> </blockquote> <p>On the other hand, if the <code>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>Allow</code>.</p> <p>The presence of an <code>Order</code> directive can affect access to a part of the server even in the absence of accompanying <code>Allow</code> and <code>Deny</code> directives because of its effect on the default access state. For example,</p> <blockquote> <code><Directory /www><br /> Order Allow,Deny<br /> </Directory></code> </blockquote> <p>will Deny all access to the <code>/www</code> directory because the default access state is set to <code>Deny</code>.</p> <p>The <code>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>Allow</code> or <code>Deny</code> directive occurring in a <Location> section will always be evaluated after an <code>Allow</code> or <code>Deny</code> directive occurring in a <Directory> section or <code>.htaccess</code> file, regardless of the setting of the <code>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> <p>See also: <a href="#deny">Deny</a> and <a href="#allow">Allow</a>. <hr /> <h3 align="CENTER">Apache HTTP Server Version 1.3</h3> <a href="./"><img src="../images/index.gif" alt="Index" /></a> <a href="../"><img src="../images/home.gif" alt="Home" /></a> </p> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -