]> granicus.if.org Git - apache/blob - docs/manual/rewrite/flags.html.en
Adding a flags document. Not yet linked from anywhere. Will link once
[apache] / docs / manual / rewrite / flags.html.en
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 Flags - 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.3</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.3</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Flags</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="../en/rewrite/flags.html" title="English">&nbsp;en&nbsp;</a></p>
22 </div>
23
24 <p>This document discusses the flags which are available to the
25 <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> directive,
26 providing more detailed explanations and examples of each.</p>
27 </div>
28 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#introduction">Introduction</a></li>
29 <li><img alt="" src="../images/down.gif" /> <a href="#flags">The flags</a></li>
30 </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="rewrite_tech.html">Technical details</a></li><li><a href="rewrite_guide.html">Practical solutions to common
31 problems</a></li><li><a href="rewrite_guide_advanced.html">Practical solutions to
32 advanced problems</a></li></ul></div>
33 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
34 <div class="section">
35 <h2><a name="introduction" id="introduction">Introduction</a></h2>
36 <p><code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>s can have
37 their behavior modified by one or more flags. Flags are included in
38 square brackets at the end of the rule, and multiple flags are separated
39 by commas.</p>
40 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
41 <div class="section">
42 <h2><a name="flags" id="flags">The flags</a></h2>
43
44 <p>Each flag has a long and short form. While it is most common to use
45 the short form, it is recommended that you familiarize yourself with the
46 long form, so that you remember what each flag is supposed to do.</p>
47
48 <p>Presented here are each of the available flags, along with an example
49 of how you might use them.</p>
50
51 <h3><a name="flag_c" id="flag_c">C|chain</a></h3>
52 <p>The [C] or [chain] flag indicates that the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> is chained to the next
53 rule. That is, if the rule matches, then it is processed as usual and
54 control moves on to the next rule. However, if it does not match, then
55 the next rule, and any other ruls that are chained together, will be
56 skipped.</p>
57
58
59
60 <h3><a name="flag_co" id="flag_co">CO|cookie</a></h3>
61 <p>The [CO], or [cookie] flag, allows you to set a cookie when a
62 particular <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>
63 matches. The argument consists of three required fields and two optional
64 fields.</p>
65 <p>You must declare a name and value for the cookie to be set, and the
66 domain for which you wish the cookie to be valid. You may optionally set
67 the lifetime of the cookie, and the path for which it should be
68 returned.</p>
69 <p>By default, the lifetime of the cookie is the current browser
70 session.</p>
71 <p>By default, the path for which the cookie will be valid is "/" - that
72 is, the entire website.</p>
73 <p>Several examples are offered here:</p>
74
75 <div class="example"><p><code>
76 RewriteEngine On<br />
77 RewriteRule ^/index.html - [CO=frontdoor=yes:.apache.org:1440:/]
78 </code></p></div>
79
80 <p>This rule doesn't rewrite the request (the "-" rewrite target tells
81 mod_rewrite to pass the request through unchanged) but sets a cookie
82 called 'frontdoor' to a value of 'yes'. The cookie is valid for any host
83 in the <code>.apache.org</code> domain. It will be set to expire in 1440
84 minutes (24 hours) and will be returned for all URIs.</p>
85
86
87
88 <h3><a name="flag_e" id="flag_e">E|env</a></h3>
89 <p>With the [E], or [env] flag, you can set the value of an environment
90 variable. Note that some variables may be set after the rule is run, and
91 so setting them in the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> won't work, since it will
92 be changed afterwards.</p>
93
94 <p>The following example sets an evironment variable called 'image' to a
95 value of '1' if the requested URI is an image file. Then, that
96 environment variable is used to exclude those requests from the access
97 log.</p>
98
99 <div class="example"><p><code>
100 RewriteRule %{REQUEST_URI} \.(png|gif|jpg) - [E=image:1]<br />
101 CustomLog logs/access_log combined env=!image
102 </code></p></div>
103
104 <p>Note that this same effect can be obtained using <code class="directive"><a href="../mod/mod_setenvif.html#setenvif">SetEnvIf</a></code>. This technique is offered as
105 an example, not as a recommendation.</p>
106
107
108 <h3><a name="flag_f" id="flag_f">F|forbidden</a></h3>
109 <p>Forbidden flag</p>
110
111
112 <h3><a name="flag_g" id="flag_g">G|gone</a></h3>
113 <p>Forbidden flag</p>
114
115
116 <h3><a name="flag_h" id="flag_h">H|handler</a></h3>
117 <p>Handler flag</p>
118
119
120 <h3><a name="flag_l" id="flag_l">L|last</a></h3>
121 <p>Last flag</p>
122
123
124 <h3><a name="flag_n" id="flag_n">N|next</a></h3>
125 <p>Next round flag</p>
126
127
128 <h3><a name="flag_nc" id="flag_nc">NC|nocase</a></h3>
129 <p>No case flag</p>
130
131
132 <h3><a name="flag_ne" id="flag_ne">NE|noescape</a></h3>
133 <p>No escape flag</p>
134
135
136 <h3><a name="flag_ns" id="flag_ns">NS|nosubreq</a></h3>
137 <p>No internal subrequest flag</p>
138
139
140 <h3><a name="flag_p" id="flag_p">P|proxy</a></h3>
141 <p>Proxy flag</p>
142
143
144 <h3><a name="flag_pt" id="flag_pt">PT|passthrough</a></h3>
145 <p>Passthrough flag</p>
146
147
148 <h3><a name="flag_pt" id="flag_pt">PT|passthrough</a></h3>
149 <p>Passthrough flag</p>
150
151
152 <h3><a name="flag_qsa" id="flag_qsa">QSA|qsappend</a></h3>
153 <p>Query String Append flag</p>
154
155
156 <h3><a name="flag_r" id="flag_r">R|redirect</a></h3>
157 <p>Redirect flag</p>
158
159
160 <h3><a name="flag_s" id="flag_s">S|skip</a></h3>
161 <p>Skip flag</p>
162
163
164 <h3><a name="flag_t" id="flag_t">T|type</a></h3>
165 <p>Type flag</p>
166
167
168 </div></div>
169 <div class="bottomlang">
170 <p><span>Available Languages: </span><a href="../en/rewrite/flags.html" title="English">&nbsp;en&nbsp;</a></p>
171 </div><div id="footer">
172 <p class="apache">Copyright 1995-2006 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
173 <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>
174 </body></html>