📄 mod_rewrite.html.en
字号:
the strings <em>Substitution</em> and <em>TestString</em>. Figure 2 shows to which locations the back-references are transfered for expansion. <div align="CENTER"> <table cellspacing="0" cellpadding="2" border="0"> <tr> <td bgcolor="#CCCCCC"><img src="../images/mod_rewrite_fig2.gif" width="381" height="179" alt="[Needs graphics capability to display]" /></td> </tr> <tr> <td align="CENTER"><strong>Figure 2:</strong> The back-reference flow through a rule</td> </tr> </table> </div> <p>We know this was a crash course on mod_rewrite's internal processing. But you will benefit from this knowledge when reading the following documentation of the available directives.</p> <hr noshade="noshade" size="1" /> <center> <h1><a id="Configuration" name="Configuration">Configuration Directives</a></h1> </center> <hr noshade="noshade" size="1" /> <h3><a id="RewriteEngine" name="RewriteEngine">RewriteEngine</a></h3> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> RewriteEngine on|off<br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> <code>RewriteEngine off</code><br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> server config, virtual host, directory, .htaccess<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> FileInfo<br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Extension<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_rewrite.c<br /> <a href="directive-dict.html#Compatibility" rel="Help"><strong>Compatibility:</strong></a> Apache 1.2<br /> <p>The <code>RewriteEngine</code> directive enables or disables the runtime rewriting engine. If it is set to <code>off</code> this module does no runtime processing at all. It does not even update the <code>SCRIPT_URx</code> environment variables.</p> <p>Use this directive to disable the module instead of commenting out all the <code>RewriteRule</code> directives!</p> <p>Note that, by default, rewrite configurations are not inherited. This means that you need to have a <code>RewriteEngine on</code> directive for each virtual host in which you wish to use it.</p> <hr noshade="noshade" size="1" /> <h3><a id="RewriteOptions" name="RewriteOptions">RewriteOptions</a></h3> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> RewriteOptions <em>Option</em><br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> <code>RewriteOptions MaxRedirects=10</code><br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> server config, virtual host, directory, .htaccess<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> FileInfo<br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Extension<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_rewrite.c<br /> <a href="directive-dict.html#Compatibility" rel="Help"><strong>Compatibility:</strong></a> Apache 1.2; <code>MaxRedirects</code> is available in Apache 1.3.28 and later<br /> <p>The <code>RewriteOptions</code> directive sets some special options for the current per-server or per-directory configuration. The <em>Option</em> strings can be one of the following:</p> <dl> <dt><code>inherit</code></dt> <dd>This forces the current configuration to inherit the configuration of the parent. In per-virtual-server context this means that the maps, conditions and rules of the main server are inherited. In per-directory context this means that conditions and rules of the parent directory's <code>.htaccess</code> configuration are inherited.</dd> <dt><code>MaxRedirects=<var>number</var></code></dt> <dd>In order to prevent endless loops of internal redirects issued by per-directory <code>RewriteRule</code>s, <code>mod_rewrite</code> aborts the request after reaching a maximum number of such redirects and responds with an 500 Internal Server Error. If you really need more internal redirects than 10 per request, you may increase the default to the desired value.</dd> </dl> <hr noshade="noshade" size="1" /> <h3><a id="RewriteLog" name="RewriteLog">RewriteLog</a></h3> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> RewriteLog <em>file-path</em><br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> <em>None</em><br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> server config, virtual host<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> <em>Not applicable</em><br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Extension<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_rewrite.c<br /> <a href="directive-dict.html#Compatibility" rel="Help"><strong>Compatibility:</strong></a> Apache 1.2<br /> <p>The <code>RewriteLog</code> directive sets the name of the file to which the server logs any rewriting actions it performs. If the name does not begin with a slash ('<code>/</code>') then it is assumed to be relative to the <em>Server Root</em>. The directive should occur only once per server config.</p> <table width="70%" border="0" bgcolor="#E0E0F0" cellspacing="0" cellpadding="10"> <tr> <td><strong>Note</strong>: To disable the logging of rewriting actions it is not recommended to set <em>file-path</em> to <code>/dev/null</code>, because although the rewriting engine does not then output to a logfile it still creates the logfile output internally. <strong>This will slow down the server with no advantage to the administrator!</strong> To disable logging either remove or comment out the <code>RewriteLog</code> directive or use <code>RewriteLogLevel 0</code>!</td> </tr> </table> <table width="70%" border="0" bgcolor="#E0E0F0" cellspacing="0" cellpadding="10"> <tr> <td><strong>Security</strong>: See the <a href="../misc/security_tips.html">Apache Security Tips</a> document for details on why your security could be compromised if the directory where logfiles are stored is writable by anyone other than the user that starts the server.</td> </tr> </table> <p><strong>Example:</strong></p> <blockquote><pre>RewriteLog "/usr/local/var/apache/logs/rewrite.log"</pre> </blockquote> <hr noshade="noshade" size="1" /> <h3><a id="RewriteLogLevel" name="RewriteLogLevel">RewriteLogLevel</a></h3> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> RewriteLogLevel <em>Level</em><br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> <code>RewriteLogLevel 0</code><br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> server config, virtual host<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> <em>Not applicable</em><br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Extension<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_rewrite.c<br /> <a href="directive-dict.html#Compatibility" rel="Help"><strong>Compatibility:</strong></a> Apache 1.2<br /> <p>The <code>RewriteLogLevel</code> directive sets the verbosity level of the rewriting logfile. The default level 0 means no logging, while 9 or more means that practically all actions are logged.</p> <p>To disable the logging of rewriting actions simply set <em>Level</em> to 0. This disables all rewrite action logs.</p> <table width="70%" border="0" bgcolor="#E0E0F0" cellspacing="0" cellpadding="10"> <tr> <td><strong>Notice:</strong> Using a high value for <em>Level</em> will slow down your Apache server dramatically! Use the rewriting logfile at a <em>Level</em> greater than 2 only for debugging!</td> </tr> </table> <p><strong>Example:</strong></p> <blockquote><pre>RewriteLogLevel 3</pre> </blockquote> <hr noshade="noshade" size="1" /> <h3><a id="RewriteLock" name="RewriteLock">RewriteLock</a></h3> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> RewriteLock <em>file-path</em><br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> <em>None</em><br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> server config<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> <em>Not applicable</em><br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Extension<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_rewrite.c<br /> <a href="directive-dict.html#Compatibility" rel="Help"><strong>Compatibility:</strong></a> Apache 1.3<br /> <p>This directive sets the filename for a synchronization lockfile which mod_rewrite needs to communicate with <samp>RewriteMap</samp> <em>programs</em>. Set this lockfile to a local path (not on a NFS-mounted device) when you want to use a rewriting map-program. It is not required for other types of rewriting maps.</p> <hr noshade="noshade" size="1" /> <h3><a id="RewriteMap" name="RewriteMap">RewriteMap</a></h3> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em><br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> not used per default<br /> <a href="directive-dict.html#Context" rel="Help"><strong>Context:</strong></a> server config, virtual host<br /> <a href="directive-dict.html#Override" rel="Help"><strong>Override:</strong></a> <em>Not applicable</em><br /> <a href="directive-dict.html#Status" rel="Help"><strong>Status:</strong></a> Extension<br /> <a href="directive-dict.html#Module" rel="Help"><strong>Module:</strong></a> mod_rewrite.c<br /> <a href="directive-dict.html#Compatibility" rel="Help"><strong>Compatibility:</strong></a> Apache 1.2 (partially), Apache 1.3<br /> <p>The <code>RewriteMap</code> directive defines a <em>Rewriting Map</em> which can be used inside rule substitution strings by the mapping-functions to insert/substitute fields through a key lookup. The source of this lookup can be of various types.</p> <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is the name of the map and will be used to specify a mapping-function for the substitution strings of a rewriting rule via one of the following constructs:</p> <blockquote> <strong><code>${</code> <em>MapName</em> <code>:</code> <em>LookupKey</em> <code>}</code><br /> <code>${</code> <em>MapName</em> <code>:</code> <em>LookupKey</em> <code>|</code> <em>DefaultValue</em> <code>}</code></strong> </blockquote> When such a construct occurs the map <em>MapName</em> is consulted and the key <em>LookupKey</em> is looked-up. If the key is found, the map-function construct is substituted by <em>SubstValue</em>. If the key is not found then it is substituted by <em>DefaultValue</em> or by the empty string if no <em>DefaultValue</em> was specified. <p>The following combinations for <em>MapType</em> and <em>MapSource</em> can be used:</p> <ul> <li> <strong>Standard Plain Text</strong><br /> MapType: <code>txt</code>, MapSource: Unix filesystem path to valid regular file <p>This is the standard rewriting map feature where the <em>MapSource</em> is a plain ASCII file containing either blank lines, comment lines (starting with a '#' character) or pairs like the following - one per line.</p> <blockquote> <strong><em>MatchingKey</em> <em>SubstValue</em></strong> </blockquote> <p>Example:</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -