~ubuntu-branches/ubuntu/hardy/apache2/hardy-proposed

« back to all changes in this revision

Viewing changes to docs/manual/mod/mod_rewrite.html.en

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Fritsch
  • Date: 2008-01-17 20:27:56 UTC
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20080117202756-hv38rjknhwa2ilwi
Tags: upstream-2.2.8
ImportĀ upstreamĀ versionĀ 2.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
436
436
        value of a header sent in the HTTP request.
437
437
        Example: <code>%{HTTP:Proxy-Connection}</code> is
438
438
        the value of the HTTP header
439
 
        ``<code>Proxy-Connection:</code>''.</li>
 
439
        ``<code>Proxy-Connection:</code>''.
 
440
        <p>If a HTTP header is used in a condition this header is added to
 
441
        the Vary header of the response in case the condition evaluates to
 
442
        to true for the request. It is <strong>not</strong> added if the
 
443
        condition evaluates to false for the request. Adding the HTTP header
 
444
        to the Vary header of the response is needed for proper caching.</p>
 
445
        <p>It has to be kept in mind that conditions follow a short circuit
 
446
        logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
 
447
        so that certain conditions might not be evaluated at all.</p></li>
440
448
 
441
449
        <li>
442
450
        <code>%{LA-U:variable}</code> can be used for look-aheads which perform
594
602
          Without this flag you would have to write the condition/rule
595
603
          pair three times.
596
604
        </li>
 
605
 
 
606
        <li>'<strong><code>novary|NV</code></strong>'
 
607
        (<strong>n</strong>o <strong>v</strong>ary)<br />
 
608
        If a HTTP header is used in the condition, this flag prevents
 
609
        this header from being added to the Vary header of the response. <br />
 
610
        Using this flag might break proper caching of the response if
 
611
        the representation of this response varies on the value of this header.
 
612
        So this flag should be only used if the meaning of the Vary header
 
613
        is well understood.
 
614
        </li>
597
615
      </ul>
598
616
      </li>
599
617
     </ol>
1078
1096
</pre></div>
1079
1097
 
1080
1098
      <p>For more information about regular expressions, have a look at the
1081
 
      perl regular expression manpage ("<a href="http://www.perldoc.com/perlre.html">perldoc
 
1099
      perl regular expression manpage ("<a href="http://perldoc.perl.org/perlre.html">perldoc
1082
1100
      perlre</a>"). If you are interested in more detailed
1083
1101
      information about regular expressions and their variants
1084
1102
      (POSIX regex etc.) the following book is dedicated to this topic:</p>
1123
1141
        <dd>A <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
1124
1142
        resource to be served. Note that <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
1125
1143
        tries to guess whether you have specified a file-system path
1126
 
        or a URL-path by checking to see if the first segement of the
 
1144
        or a URL-path by checking to see if the first segment of the
1127
1145
        path exists at the root of the file-system. For example, if
1128
1146
        you specify a <em>Substitution</em> string of
1129
1147
        <code>/www/file.html</code>, then this will be treated as a
1207
1225
      brackets, of any of the following flags: </p>
1208
1226
 
1209
1227
      <dl>
 
1228
        <dt>'<code>B</code>' (escape backreferences)</dt>
 
1229
        <dd><p>Apache has to unescape URLs before mapping them,
 
1230
        so backreferences will be unescaped at the time they are applied.
 
1231
        Using the B flag, non-alphanumeric characters in backreferences
 
1232
        will be escaped.  For example, consider the rule:</p>
 
1233
        <pre><code> RewriteRule ^(.*)$ index.php?show=$1 </code></pre>
 
1234
        <p>This will map <code>/C++</code> to <code>index.php?show=C++</code>.
 
1235
        But it will also map <code>/C%2b%2b</code> to
 
1236
        <code>index.php?show=C++</code>, because the <code>%2b</code>
 
1237
        has been unescaped.  With the B flag, it will instead map to
 
1238
        <code>index.php?show=&gt;/C%2b%2b</code>.</p>
 
1239
        <p>This escaping is particularly necessary in a proxy situation,
 
1240
        when the backend may break if presented with an unescaped URL.</p>
 
1241
        </dd>
 
1242
 
1210
1243
        <dt>'<code>chain|C</code>'
1211
1244
        (chained with next rule)</dt><dd>
1212
1245
         This flag chains the current rule with the next rule
1220
1253
        when you let an external redirect happen (where the
1221
1254
        ``<code>.www</code>'' part should not occur!).</dd>
1222
1255
 
1223
 
        <dt>
1224
 
                '<code>cookie|CO=</code><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>]]'
 
1256
        <dt>'<code>cookie|CO=</code><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>]]'
1225
1257
        (set cookie)</dt><dd>
1226
1258
        This sets a cookie in the client's browser.  The cookie's name
1227
1259
        is specified by <em>NAME</em> and the value is
1461
1493
        </dd>
1462
1494
      </dl>
1463
1495
 
 
1496
<div class="note"><h3>Home directory expansion</h3>
 
1497
<p> When the substitution string begins with a string
 
1498
resembling "/~user" (via explicit text or backreferences), mod_rewrite performs
 
1499
home directory expansion independent of the presence or configuration
 
1500
of <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code>.</p>
 
1501
 
 
1502
<p> This expansion does not occur when the <em>PT</em>
 
1503
flag is used on the <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
 
1504
directive.</p>
 
1505
</div>
 
1506
 
1464
1507
<div class="note"><h3>Per-directory Rewrites</h3>
1465
1508
 
1466
1509
<p>The rewrite engine may be used in <a href="../howto/htaccess.html">.htaccess</a> files.  To enable the