mod_rewrite.html.en

来自「apache的软件linux版本」· EN 代码 · 共 1,362 行 · 第 1/5 页

EN
1,362
字号
      <em>TestString</em> is first evaluated, before being matched against      <em>CondPattern</em>.</p>      <p><strong>Remember:</strong> <em>CondPattern</em> is a      <em>perl compatible regular expression</em> with some      additions:</p>      <ol>        <li>You can prefix the pattern string with a        '<code>!</code>' character (exclamation mark) to specify a        <strong>non</strong>-matching pattern.</li>        <li>          There are some special variants of <em>CondPatterns</em>.          Instead of real regular expression strings you can also          use one of the following:           <ul>                        <li>'<strong>&lt;CondPattern</strong>' (lexicographically            precedes)<br />            Treats the <em>CondPattern</em> as a plain string and            compares it lexicographically to <em>TestString</em>. True if            <em>TestString</em> lexicographically precedes            <em>CondPattern</em>.</li>            <li>'<strong>&gt;CondPattern</strong>' (lexicographically            follows)<br />            Treats the <em>CondPattern</em> as a plain string and            compares it lexicographically to <em>TestString</em>. True if            <em>TestString</em> lexicographically follows	    <em>CondPattern</em>.</li>            <li>'<strong>=CondPattern</strong>' (lexicographically            equal)<br />            Treats the <em>CondPattern</em> as a plain string and            compares it lexicographically to <em>TestString</em>. True if            <em>TestString</em> is lexicographically equal to            <em>CondPattern</em> (the two strings are exactly            equal, character for character). If <em>CondPattern</em>            is <code>""</code> (two quotation marks) this            compares <em>TestString</em> to the empty string.</li>            <li>'<strong>-d</strong>' (is            <strong>d</strong>irectory)<br />             Treats the <em>TestString</em> as a pathname and tests            whether or not it exists, and is a directory.</li>            <li>'<strong>-f</strong>' (is regular            <strong>f</strong>ile)<br />             Treats the <em>TestString</em> as a pathname and tests            whether or not it exists, and is a regular file.</li>            <li>'<strong>-s</strong>' (is regular file, with            <strong>s</strong>ize)<br />            Treats the <em>TestString</em> as a pathname and tests            whether or not it exists, and is a regular file with size greater            than zero.</li>            <li>'<strong>-l</strong>' (is symbolic            <strong>l</strong>ink)<br />            Treats the <em>TestString</em> as a pathname and tests            whether or not it exists, and is a symbolic link.</li>            <li>'<strong>-F</strong>' (is existing file, via            subrequest)<br />            Checks whether or not <em>TestString</em> is a valid file,            accessible via all the server's currently-configured            access controls for that path. This uses an internal            subrequest to do the check, so use it with care -            it can impact your server's performance!</li>            <li>'<strong>-U</strong>' (is existing URL, via            subrequest)<br />            Checks whether or not <em>TestString</em> is a valid URL,            accessible via all the server's currently-configured            access controls for that path. This uses an internal            subrequest to do the check, so use it with care -            it can impact your server's performance!</li>          </ul><div class="note"><h3>Note</h3>              All of these tests can              also be prefixed by an exclamation mark ('!') to              negate their meaning.</div>        </li>        <li>You can also set special flags for      <em>CondPattern</em> by appending        <strong><code>[</code><em>flags</em><code>]</code></strong>      as the third argument to the <code>RewriteCond</code>      directive, where <em>flags</em> is a comma-separated list of any of the      following flags:      <ul>        <li>'<strong><code>nocase|NC</code></strong>'        (<strong>n</strong>o <strong>c</strong>ase)<br />        This makes the test case-insensitive - differences        between 'A-Z' and 'a-z' are ignored, both in the        expanded <em>TestString</em> and the <em>CondPattern</em>.        This flag is effective only for comparisons between        <em>TestString</em> and <em>CondPattern</em>. It has no        effect on filesystem and subrequest checks.</li>        <li>          '<strong><code>ornext|OR</code></strong>'          (<strong>or</strong> next condition)<br />          Use this to combine rule conditions with a local OR          instead of the implicit AND. Typical example:<div class="example"><pre>RewriteCond %{REMOTE_HOST}  ^host1.*  [OR]RewriteCond %{REMOTE_HOST}  ^host2.*  [OR]RewriteCond %{REMOTE_HOST}  ^host3.*RewriteRule ...some special stuff for any of these hosts...</pre></div>          Without this flag you would have to write the condition/rule          pair three times.        </li>      </ul>      </li>     </ol>      <p><strong>Example:</strong></p>       <p>To rewrite the Homepage of a site according to the        ``<code>User-Agent:</code>'' header of the request, you can        use the following: </p><div class="example"><pre>RewriteCond  %{HTTP_USER_AGENT}  ^Mozilla.*RewriteRule  ^/$                 /homepage.max.html  [L]RewriteCond  %{HTTP_USER_AGENT}  ^Lynx.*RewriteRule  ^/$                 /homepage.min.html  [L]RewriteRule  ^/$                 /homepage.std.html  [L]</pre></div>        <p>Explanation: If you use a browser which identifies itself        as 'Mozilla' (including Netscape Navigator, Mozilla etc), then you        get the max homepage (which could include frames, or other special        features).        If you use the Lynx browser (which is terminal-based), then        you get the min homepage (which could be a version designed for        easy, text-only browsing).        If neither of these conditions apply (you use any other browser,        or your browser identifies itself as something non-standard), you get        the std (standard) homepage.</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="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr><tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr><tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr></table>             <p>The <code class="directive">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 class="directive"><a href="#rewriterule">RewriteRule</a></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></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="RewriteLock" id="RewriteLock">RewriteLock</a> <a name="rewritelock" id="rewritelock">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the lock file used for <code class="directive"><a href="#rewritemap">RewriteMap</a></code>synchronization</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLock <em>file-path</em></code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr></table>      <p>This directive sets the filename for a synchronization      lockfile which mod_rewrite needs to communicate with <code class="directive"><a href="#rewritemap">RewriteMap</a></code>      <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></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="RewriteLog" id="RewriteLog">RewriteLog</a> <a name="rewritelog" id="rewritelog">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the file used for logging rewrite engineprocessing</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLog <em>file-path</em></code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr></table>      <p>The <code class="directive">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><div class="note">    To disable the logging of          rewriting actions it is not recommended to set          <em>Filename</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 class="directive">RewriteLog</code>          directive or use <code>RewriteLogLevel 0</code>!</div><div class="note"><h3>Security</h3>See the <a href="../misc/security_tips.html">Apache Security Tips</a>document for details on how your security could be compromised if thedirectory where logfiles are stored is writable by anyone other thanthe user that starts the server.</div><div class="example"><h3>Example</h3><p><code>RewriteLog "/usr/local/var/apache/logs/rewrite.log"</code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="RewriteLogLevel" id="RewriteLogLevel">RewriteLogLevel</a> <a name="rewriteloglevel" id="rewriteloglevel">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the verbosity of the log file used by the rewriteengine</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLogLevel <em>Level</em></code></td></tr><tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteLogLevel 0</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr></table>      <p>The <code class="directive">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><div class="note"> 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!</div><div class="example"><h3>Example</h3><p><code>RewriteLogLevel 3</code></p></div></div>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?