~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to docs/manual/rewrite/rewrite_intro.html.en

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="ISO-8859-1"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
 
4
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
5
              This file is generated from xml source: DO NOT EDIT
 
6
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
7
      -->
 
8
<title>Apache mod_rewrite Introduction - Apache HTTP Server</title>
 
9
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
 
10
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
 
11
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
 
12
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
 
13
<body id="manual-page"><div id="page-header">
 
14
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
 
15
<p class="apache">Apache HTTP Server Version 2.2</p>
 
16
<img alt="" src="../images/feather.gif" /></div>
 
17
<div class="up"><a href="./index.html"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
 
18
<div id="path">
 
19
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.2</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Introduction</h1>
 
20
<div class="toplang">
 
21
<p><span>Available Languages: </span><a href="../en/rewrite/rewrite_intro.html" title="English">&nbsp;en&nbsp;</a></p>
 
22
</div>
 
23
 
 
24
<p>This document supplements the <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
 
25
<a href="../mod/mod_rewrite.html">reference documentation</a>. It
 
26
describes the basic concepts necessary for use of
 
27
<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. Other documents go into greater detail,
 
28
but this doc should help the beginner get their feet wet.
 
29
</p>
 
30
</div>
 
31
<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#introduction">Introduction</a></li>
 
32
<li><img alt="" src="../images/down.gif" /> <a href="#regex">Regular Expressions</a></li>
 
33
<li><img alt="" src="../images/down.gif" /> <a href="#rewriterule">RewriteRule basics</a></li>
 
34
<li><img alt="" src="../images/down.gif" /> <a href="#flags">Rewrite Flags</a></li>
 
35
<li><img alt="" src="../images/down.gif" /> <a href="#rewritecond">Rewrite conditions</a></li>
 
36
<li><img alt="" src="../images/down.gif" /> <a href="#rewritemap">Rewrite maps</a></li>
 
37
<li><img alt="" src="../images/down.gif" /> <a href="#htaccess">.htaccess files</a></li>
 
38
<li><img alt="" src="../images/down.gif" /> <a href="#EnvVar">Environment Variables</a></li>
 
39
</ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module
 
40
documentation</a></li><li><a href="rewrite_tech.html">Technical details</a></li><li><a href="rewrite_guide.html">Practical solutions to common
 
41
problems</a></li><li><a href="rewrite_guide_advanced.html">Practical solutions to
 
42
advanced problems</a></li></ul></div>
 
43
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
44
<div class="section">
 
45
<h2><a name="introduction" id="introduction">Introduction</a></h2>
 
46
<p>The Apache module <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> is a very powerful and
 
47
sophisticated module which provides a way to do URL manipulations. With
 
48
it, you can do nearly all types of URL rewriting that you may need. It
 
49
is, however, somewhat complex, and may be intimidating to the beginner.
 
50
There is also a tendency to treat rewrite rules as magic incantation,
 
51
using them without actually understanding what they do.</p>
 
52
 
 
53
<p>This document attempts to give sufficient background so that what
 
54
follows is understood, rather than just copied blindly.
 
55
</p>
 
56
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
57
<div class="section">
 
58
<h2><a name="regex" id="regex">Regular Expressions</a></h2>
 
59
 
 
60
<p>mod_rewrite uses the <a href="http://pcre.org/">Perl Compatible
 
61
Regular Expression</a> vocabulary. In this document, we do not attempt
 
62
to provide a detailed reference to regular expressions. For that, we
 
63
recommend the <a href="http://pcre.org/pcre.txt">PCRE man pages</a>, the
 
64
<a href="http://www.perldoc.com/perl5.8.0/pod/perlre.html">Perl regular
 
65
expression man page</a>, and <a href="http://www.oreilly.com/catalog/regex2/index.html">Mastering
 
66
Regular Expressions, by Jeffrey Friedl</a>.</p>
 
67
 
 
68
<p>In this document, we attempt to provide enough of a regex vocabulary
 
69
to get you started, without being overwhelming, in the hope that
 
70
<code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>s will be scientific
 
71
formulae, rather than magical incantations.</p>
 
72
 
 
73
<h3><a name="regexvocab" id="regexvocab">Regex vocabulary</a></h3>
 
74
 
 
75
<p>The following are the minimal building blocks you will need, in order
 
76
to write regular expressions and <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>s. They certainly do not
 
77
represent a complete regular expression vocabulary, but they are a good
 
78
place to start, and should help you read basic regular expressions, as
 
79
well as write your own.</p>
 
80
 
 
81
<table>
 
82
<tr>
 
83
<th>Character</th>
 
84
<th>Meaning</th>
 
85
<th>Example</th>
 
86
</tr>
 
87
 
 
88
<tr><td><code>.</code></td><td>Matches any
 
89
character</td><td><code>c.t</code> will match <code>cat</code>,
 
90
<code>cot</code>, <code>cut</code>, etc.</td></tr>
 
91
<tr><td><code>+</code></td><td>Repeats the previous match one or more
 
92
times</td><td><code>a+</code> matches <code>a</code>, <code>aa</code>, 
 
93
<code>aaa</code>, etc</td></tr>
 
94
<tr><td><code>*</code></td><td>Repeats the previous match zero or more
 
95
times.</td><td><code>a*</code> matches all the same things
 
96
<code>a+</code> matches, but will also match an empty string.</td></tr>
 
97
<tr><td><code>?</code></td><td>Makes the match optional.</td><td /></tr>
 
98
<tr><td><code>.</code></td><td>Matches any
 
99
character</td><td><code>colou?r</code> will match <code>color</code> and
 
100
<code>colour</code>.</td></tr>
 
101
<tr><td><code>^</code></td><td>Called an anchor, matches the beginning
 
102
of the string</td><td><code>^a</code> matches a string that begins with
 
103
<code>a</code></td></tr>
 
104
<tr><td><code>$</code></td><td>The other anchor, this matches the end of
 
105
the string.</td><td><code>a$</code> matches a string that ends with
 
106
<code>a</code>.</td></tr>
 
107
<tr><td><code>( )</code></td><td>Groups several characters into a single
 
108
unit, and captures a match for use in a backreference.</td><td><code>(ab)+</code> 
 
109
matches <code>ababab</code> - that is, the <code>+</code> applies to the group.
 
110
For more on backreferences see <a href="#InternalBackRefs">below</a>.</td></tr>
 
111
<tr><td><code>[ ]</code></td><td>A character class - matches one of the
 
112
characters</td><td><code>c[uoa]t</code> matches <code>cut</code>,
 
113
<code>cot</code> or <code>cat</code>.</td></tr>
 
114
<tr><td><code>!</code></td><td>Not</td><td>Negates a match - that is,
 
115
ensures that it does not match.</td></tr>
 
116
 
 
117
</table>
 
118
 
 
119
 
 
120
 
 
121
<h3><a name="InternalBackRefs" id="InternalBackRefs">Regex Back-Reference Availability</a></h3>
 
122
 
 
123
      <p>One important thing here has to be remembered: Whenever you
 
124
      use parentheses in <em>Pattern</em> or in one of the
 
125
      <em>CondPattern</em>, back-references are internally created
 
126
      which can be used with the strings <code>$N</code> and
 
127
      <code>%N</code> (see below). These are available for creating
 
128
      the strings <em>Substitution</em> and <em>TestString</em>.
 
129
      Figure 2 shows to which locations the back-references are
 
130
      transferred for expansion.</p>
 
131
 
 
132
<p class="figure">
 
133
      <img src="../images/mod_rewrite_fig2.gif" width="381" height="179" alt="[Needs graphics capability to display]" /><br />
 
134
      <dfn>Figure 2:</dfn> The back-reference flow through a rule.
 
135
</p>
 
136
 
 
137
 
 
138
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
139
<div class="section">
 
140
<h2><a name="rewriterule" id="rewriterule">RewriteRule basics</a></h2>
 
141
<p>
 
142
Basic anatomy of a RewriteRule, with exhaustively annotated simple
 
143
examples.
 
144
</p>
 
145
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
146
<div class="section">
 
147
<h2><a name="flags" id="flags">Rewrite Flags</a></h2>
 
148
<p>Discussion of the flags to RewriteRule, and when and why one might
 
149
use them.</p>
 
150
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
151
<div class="section">
 
152
<h2><a name="rewritecond" id="rewritecond">Rewrite conditions</a></h2>
 
153
<p>Discussion of RewriteCond, looping, and other related concepts.
 
154
</p>
 
155
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
156
<div class="section">
 
157
<h2><a name="rewritemap" id="rewritemap">Rewrite maps</a></h2>
 
158
<p>Discussion of RewriteMap, including simple, but heavily annotated,
 
159
examples.</p>
 
160
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
161
<div class="section">
 
162
<h2><a name="htaccess" id="htaccess">.htaccess files</a></h2>
 
163
<p>Discussion of the differences between rewrite rules in httpd.conf and
 
164
in .htaccess files.</p>
 
165
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
166
<div class="section">
 
167
<h2><a name="EnvVar" id="EnvVar">Environment Variables</a></h2>
 
168
 
 
169
<p>This module keeps track of two additional (non-standard)
 
170
CGI/SSI environment variables named <code>SCRIPT_URL</code>
 
171
and <code>SCRIPT_URI</code>. These contain the
 
172
<em>logical</em> Web-view to the current resource, while the
 
173
standard CGI/SSI variables <code>SCRIPT_NAME</code> and
 
174
<code>SCRIPT_FILENAME</code> contain the <em>physical</em>
 
175
System-view. </p>
 
176
 
 
177
<p>Notice: These variables hold the URI/URL <em>as they were
 
178
initially requested</em>, <em>i.e.</em>, <em>before</em> any
 
179
rewriting. This is important because the rewriting process is
 
180
primarily used to rewrite logical URLs to physical
 
181
pathnames.</p>
 
182
 
 
183
<div class="example"><h3>Example</h3><pre>
 
184
SCRIPT_NAME=/sw/lib/w3s/tree/global/u/rse/.www/index.html
 
185
SCRIPT_FILENAME=/u/rse/.www/index.html
 
186
SCRIPT_URL=/u/rse/
 
187
SCRIPT_URI=http://en1.engelschall.com/u/rse/
 
188
</pre></div>
 
189
 
 
190
</div></div>
 
191
<div class="bottomlang">
 
192
<p><span>Available Languages: </span><a href="../en/rewrite/rewrite_intro.html" title="English">&nbsp;en&nbsp;</a></p>
 
193
</div><div id="footer">
 
194
<p class="apache">Copyright 2006 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
 
195
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
 
196
</body></html>
 
 
b'\\ No newline at end of file'