📄 mod_access.html.en
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content="HTML Tidy, see www.w3.org" /> <title>Apache module mod_access</title> </head> <!-- Background white, links blue (unvisited), navy (visited), red (active) --> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#000080" alink="#FF0000"> <div align="CENTER"> <img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]" /> <h3>Apache HTTP Server Version 1.3</h3> <p><small><em>Is this the version you want? For more recent versions, check our <a href="/docs/">documentation index</a>.</em></small></p> </div> <h1 align="center">Module mod_access</h1> <p>This module provides access control based on client hostname, IP address, or other characteristics of the client request.</p> <p><a href="module-dict.html#Status" rel="Help"><strong>Status:</strong></a> Base<br /> <a href="module-dict.html#SourceFile" rel="Help"><strong>Source File:</strong></a> mod_access.c<br /> <a href="module-dict.html#ModuleIdentifier" rel="Help"><strong>Module Identifier:</strong></a> access_module</p> <h2>Summary</h2> <p>The directives provided by mod_access are used in <code><a href="core.html#directory"><Directory></a>, <a href="core.html#files"><Files></a>,</code> and <code><a href="core.html#location"><Location></a></code> sections as well as <code><a href="core.html#accessfilename">.htaccess</a></code> files to control access to particular parts of the server. Access can be controlled based on the client hostname, IP address, or other characteristics of the client request, as captured in <a href="../env.html">environment variables</a>. The <code>Allow</code> and <code>Deny</code> directives are used to specify which clients are or are not allowed access to the server, while the <code>Order</code> directive sets the default access state, and configures how the <code>Allow</code> and <code>Deny</code> directives interact with each other.</p> <p>Both host-based access restrictions and password-based authentication may be implemented simultaneously. In that case, the <a href="core.html#satisfy">Satisfy</a> directive is used to determine how the two sets of restrictions interact.</p> <p>In general, access restriction directives apply to all access methods (<code>GET</code>, <code>PUT</code>, <code>POST</code>, etc). This is the desired behavior in most cases. However, it is possible to restrict some methods, while leaving other methods unrestricted, by enclosing the directives in a <a href="core.html#limit"><Limit></a> section.</p> <h2>Directives</h2> <ul> <li><a href="#allow">Allow</a></li> <li><a href="#deny">Deny</a></li> <li><a href="#order">Order</a></li> </ul> <p>See also <a href="core.html#satisfy">Satisfy</a> and <a href="core.html#require">Require</a>.</p> <hr /> <h2><a id="allow" name="allow">Allow</a> <a id="allowfromenv" name="allowfromenv">directive</a></h2> <p> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> Allow 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>The <code>Allow</code> directive affects which hosts can access an area of the server. Access can be controlled by hostname, IP address, IP address range, or other characteristics of the client request captured in environment variables.</p> <p>The first argument to this directive is always <code>from</code>. The subsequent arguments can take three different forms. If <code>Allow from all</code> is specified, then all hosts are allowed access, subject to the configuration of the <code>Deny</code> and <code>Order</code> directives as discussed below. To allow only particular hosts or groups of hosts to access the server, the <em>host</em> can be specified in any of the following formats:</p> <dl> <dt>A (partial) domain-name</dt> <dd>Example: <code>Allow from apache.org</code><br /> Hosts whose names match, or end in, this string are allowed access. Only complete components are matched, so the above example will match <code>foo.apache.org</code> but it will not match <code>fooapache.org</code>. This configuration will cause the server to perform a double reverse DNS lookup on the client IP address, regardless of the setting of the <a href="core.html#hostnamelookups">HostnameLookups</a> directive. It will do a reverse DNS lookup on the IP address to find the associated hostname, and then do a forward lookup on the hostname to assure that it matches the original IP address. Only if the forward and reverse DNS are consistent and the hostname matches will access be allowed.</dd> <dt>A full IP address</dt> <dd>Example: <code>Allow from 10.1.2.3</code><br /> An IP address of a host allowed access</dd> <dt>A partial IP address</dt> <dd>Example: <code>Allow from 10.1</code><br /> The first 1 to 3 bytes of an IP address, for subnet restriction.</dd> <dt>A network/netmask pair</dt> <dd>Example: <code>Allow from 10.1.0.0/255.255.0.0</code><br /> A network a.b.c.d, and a netmask w.x.y.z. For more fine-grained subnet restriction. (Apache 1.3 and later)</dd> <dt>A network/nnn CIDR specification</dt> <dd>Example: <code>Allow from 10.1.0.0/16</code><br /> Similar to the previous case, except the netmask consists of nnn high-order 1 bits. (Apache 1.3 and later)</dd> </dl> <p>Note that the last three examples above match exactly the same set of hosts.</p> <p>The third format of the arguments to the <code>Allow</code> directive allows access to the server to be controlled based on the existence of an <a href="../env.html">environment variable</a>. When <code>Allow from env=</code><em>env-variable</em> is specified, then the request is allowed access if the environment variable <em>env-variable</em> exists. The server provides the ability to set environment variables in a flexible way based on characteristics of the client request using the directives provided by <a href="mod_setenvif.html">mod_setenvif</a>. Therefore, this directive can be used to allow access based on such factors as the clients <code>User-Agent</code> (browser type), <code>Referer</code>, or other HTTP request header fields.</p> <p>Example:</p> <blockquote><pre>SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in<Directory /docroot> Order Deny,Allow Deny from all Allow from env=let_me_in</Directory></pre> </blockquote> <p>In this case, browsers with a user-agent string beginning with <tt>KnockKnock/2.0</tt> will be allowed access, and all others will be denied.</p> <p>See also <a href="#deny">Deny</a>, <a href="#order">Order</a> and <a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -