flags.xml revision c5a8b26db25c8bad3b217582e598026bc39d98be
52ea316008e2581c8113441c9c341e5c65225f6anilgun<?xml version='1.0' encoding='UTF-8' ?>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
52ea316008e2581c8113441c9c341e5c65225f6anilgun<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<!-- $LastChangedRevision$ -->
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<!--
52ea316008e2581c8113441c9c341e5c65225f6anilgun Copyright 2002-2006 The Apache Software Foundation or its licensors, as
52ea316008e2581c8113441c9c341e5c65225f6anilgun applicable.
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun Licensed under the Apache License, Version 2.0 (the "License");
52ea316008e2581c8113441c9c341e5c65225f6anilgun you may not use this file except in compliance with the License.
52ea316008e2581c8113441c9c341e5c65225f6anilgun You may obtain a copy of the License at
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun http://www.apache.org/licenses/LICENSE-2.0
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun Unless required by applicable law or agreed to in writing, software
52ea316008e2581c8113441c9c341e5c65225f6anilgun distributed under the License is distributed on an "AS IS" BASIS,
52ea316008e2581c8113441c9c341e5c65225f6anilgun WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52ea316008e2581c8113441c9c341e5c65225f6anilgun See the License for the specific language governing permissions and
52ea316008e2581c8113441c9c341e5c65225f6anilgun limitations under the License.
52ea316008e2581c8113441c9c341e5c65225f6anilgun-->
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<manualpage metafile="flags.xml.meta">
52ea316008e2581c8113441c9c341e5c65225f6anilgun<parentdocument href="/index.html"/>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun <title>Apache mod_rewrite Flags</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<summary>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>This document discusses the flags which are available to the
52ea316008e2581c8113441c9c341e5c65225f6anilgun<directive module="mod_rewrite">RewriteRule</directive> directive,
52ea316008e2581c8113441c9c341e5c65225f6anilgunproviding more detailed explanations and examples of each.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</summary>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<seealso><a href="/mod/mod_rewrite.html">Module documentation</a></seealso>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<seealso><a href="rewrite_tech.html">Technical details</a></seealso>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<seealso><a href="rewrite_guide.html">Rewrite Guide - useful examples</a></seealso>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<seealso><a href="rewrite_guide_advanced.html">Advanced Rewrite Guide -
52ea316008e2581c8113441c9c341e5c65225f6anilgunadvanced useful examples</a></seealso>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="introduction"><title>Introduction</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p><directive module="mod_rewrite">RewriteRule</directive>s can have
52ea316008e2581c8113441c9c341e5c65225f6anilguntheir behavior modified by one or more flags. Flags are included in
52ea316008e2581c8113441c9c341e5c65225f6anilgunsquare brackets at the end of the rule, and multiple flags are separated
52ea316008e2581c8113441c9c341e5c65225f6anilgunby commas.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<example>
52ea316008e2581c8113441c9c341e5c65225f6anilgunRewriteRule pattern target [Flag1,Flag2,Flag3]
52ea316008e2581c8113441c9c341e5c65225f6anilgun</example>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>The flags all have a short form, such as <code>CO</code>, as well as
52ea316008e2581c8113441c9c341e5c65225f6anilguna longer form, such as <code>cookie</code>. Some flags take one or more
52ea316008e2581c8113441c9c341e5c65225f6anilgunarguments. Flags are not case sensitive.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flags"><title>The flags</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Each flag has a long and short form. While it is most common to use
52ea316008e2581c8113441c9c341e5c65225f6anilgunthe short form, it is recommended that you familiarize yourself with the
52ea316008e2581c8113441c9c341e5c65225f6anilgunlong form, so that you remember what each flag is supposed to do.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Presented here are each of the available flags, along with an example
52ea316008e2581c8113441c9c341e5c65225f6anilgunof how you might use them.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_c"><title>C|chain</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>The [C] or [chain] flag indicates that the <directive
52ea316008e2581c8113441c9c341e5c65225f6anilgunmodule="mod_rewrite">RewriteRule</directive> is chained to the next
52ea316008e2581c8113441c9c341e5c65225f6anilgunrule. That is, if the rule matches, then it is processed as usual and
52ea316008e2581c8113441c9c341e5c65225f6anilguncontrol moves on to the next rule. However, if it does not match, then
52ea316008e2581c8113441c9c341e5c65225f6anilgunthe next rule, and any other rules that are chained together, will be
52ea316008e2581c8113441c9c341e5c65225f6anilgunskipped.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_co"><title>CO|cookie</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>The [CO], or [cookie] flag, allows you to set a cookie when a
52ea316008e2581c8113441c9c341e5c65225f6anilgunparticular <directive module="mod_rewrite">RewriteRule</directive>
52ea316008e2581c8113441c9c341e5c65225f6anilgunmatches. The argument consists of three required fields and two optional
52ea316008e2581c8113441c9c341e5c65225f6anilgunfields.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>You must declare a name and value for the cookie to be set, and the
52ea316008e2581c8113441c9c341e5c65225f6anilgundomain for which you wish the cookie to be valid. You may optionally set
52ea316008e2581c8113441c9c341e5c65225f6anilgunthe lifetime of the cookie, and the path for which it should be
52ea316008e2581c8113441c9c341e5c65225f6anilgunreturned.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>By default, the lifetime of the cookie is the current browser
52ea316008e2581c8113441c9c341e5c65225f6anilgunsession.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>By default, the path for which the cookie will be valid is "/" - that
52ea316008e2581c8113441c9c341e5c65225f6anilgunis, the entire website.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Several examples are offered here:</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<example>
52ea316008e2581c8113441c9c341e5c65225f6anilgunRewriteEngine On<br />
52ea316008e2581c8113441c9c341e5c65225f6anilgunRewriteRule ^/index.html - [CO=frontdoor=yes:.apache.org:1440:/]
52ea316008e2581c8113441c9c341e5c65225f6anilgun</example>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>This rule doesn't rewrite the request (the "-" rewrite target tells
52ea316008e2581c8113441c9c341e5c65225f6anilgunmod_rewrite to pass the request through unchanged) but sets a cookie
52ea316008e2581c8113441c9c341e5c65225f6anilguncalled 'frontdoor' to a value of 'yes'. The cookie is valid for any host
52ea316008e2581c8113441c9c341e5c65225f6anilgunin the <code>.apache.org</code> domain. It will be set to expire in 1440
52ea316008e2581c8113441c9c341e5c65225f6anilgunminutes (24 hours) and will be returned for all URIs.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_e"><title>E|env</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>With the [E], or [env] flag, you can set the value of an environment
52ea316008e2581c8113441c9c341e5c65225f6anilgunvariable. Note that some environment variables may be set after the rule
52ea316008e2581c8113441c9c341e5c65225f6anilgunis run, thus unsetting what you have set. See <a href="/env.html">the
52ea316008e2581c8113441c9c341e5c65225f6anilgunEnvironment Variables document</a> for more details on how Environment
52ea316008e2581c8113441c9c341e5c65225f6anilgunvariables work.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>The following example sets an evironment variable called 'image' to a
52ea316008e2581c8113441c9c341e5c65225f6anilgunvalue of '1' if the requested URI is an image file. Then, that
52ea316008e2581c8113441c9c341e5c65225f6anilgunenvironment variable is used to exclude those requests from the access
52ea316008e2581c8113441c9c341e5c65225f6anilgunlog.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<example>
52ea316008e2581c8113441c9c341e5c65225f6anilgunRewriteRule %{REQUEST_URI} \.(png|gif|jpg) - [E=image:1]<br />
52ea316008e2581c8113441c9c341e5c65225f6anilgunCustomLog logs/access_log combined env=!image
52ea316008e2581c8113441c9c341e5c65225f6anilgun</example>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Note that this same effect can be obtained using <directive
52ea316008e2581c8113441c9c341e5c65225f6anilgunmodule="mod_setenvif">SetEnvIf</directive>. This technique is offered as
52ea316008e2581c8113441c9c341e5c65225f6anilgunan example, not as a recommendation.</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_f"><title>F|forbidden</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Forbidden flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_g"><title>G|gone</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Gone flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_h"><title>H|handler</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Handler flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_l"><title>L|last</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Last flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_n"><title>N|next</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Next round flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_nc"><title>NC|nocase</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>No case flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_ne"><title>NE|noescape</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>No escape flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_ns"><title>NS|nosubreq</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>No internal subrequest flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_p"><title>P|proxy</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Proxy flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_pt"><title>PT|passthrough</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Passthrough flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_pt"><title>PT|passthrough</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Passthrough flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_qsa"><title>QSA|qsappend</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Query String Append flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_r"><title>R|redirect</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Redirect flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_s"><title>S|skip</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Skip flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun<section id="flag_t"><title>T|type</title>
52ea316008e2581c8113441c9c341e5c65225f6anilgun<p>Type flag</p>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun</section>
52ea316008e2581c8113441c9c341e5c65225f6anilgun</manualpage>
52ea316008e2581c8113441c9c341e5c65225f6anilgun
52ea316008e2581c8113441c9c341e5c65225f6anilgun