diff options
author | Stefan Fritsch <sf@sfritsch.de> | 2011-12-27 19:42:22 +0100 |
---|---|---|
committer | Stefan Fritsch <sf@sfritsch.de> | 2011-12-27 19:42:22 +0100 |
commit | 0268977037115539ad65a26e858aa0df8d18cd13 (patch) | |
tree | f761b541b04d08b75e32efc6c293111c61a8b79c /docs/manual/rewrite | |
parent | 9e615cb6aa4afcee97f8a1646e5a586261a7b81f (diff) | |
download | apache2-0268977037115539ad65a26e858aa0df8d18cd13.tar.gz |
Upstream tarball 2.2.9upstream/2.2.9
Diffstat (limited to 'docs/manual/rewrite')
-rw-r--r-- | docs/manual/rewrite/index.html | 2 | ||||
-rw-r--r-- | docs/manual/rewrite/index.html.en | 22 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_flags.html | 5 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_flags.html.en | 420 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_guide.html | 2 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_guide.html.en | 92 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_guide_advanced.html | 2 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_guide_advanced.html.en | 430 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_intro.html | 2 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_intro.html.en | 212 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_tech.html | 2 | ||||
-rw-r--r-- | docs/manual/rewrite/rewrite_tech.html.en | 12 |
12 files changed, 872 insertions, 331 deletions
diff --git a/docs/manual/rewrite/index.html b/docs/manual/rewrite/index.html index 5f97bff8..e4d079c3 100644 --- a/docs/manual/rewrite/index.html +++ b/docs/manual/rewrite/index.html @@ -1,3 +1,5 @@ +# GENERATED FROM XML -- DO NOT EDIT + URI: index.html.en Content-Language: en Content-type: text/html; charset=ISO-8859-1 diff --git a/docs/manual/rewrite/index.html.en b/docs/manual/rewrite/index.html.en index 2ee4200b..1b61e89d 100644 --- a/docs/manual/rewrite/index.html.en +++ b/docs/manual/rewrite/index.html.en @@ -33,7 +33,7 @@ </blockquote> <blockquote> - <p>`` Despite the tons of examples and docs, + <p>``Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.''</p> @@ -59,7 +59,8 @@ <p>This module operates on the full URLs (including the path-info part) both in per-server context (<code>httpd.conf</code>) and per-directory context - (<code>.htaccess</code>) and can even generate query-string + (<code>.htaccess</code> files and <code><Directory></code> + blocks) and can even generate query-string parts on result. The rewritten result can lead to internal sub-processing, external request redirection or even to an internal proxy throughput.</p> @@ -69,10 +70,8 @@ entire module in just one day.</p> </div> -<div id="quickview"><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">mod_rewrite reference -documentation</a></li><li><a href="rewrite_intro.html">Introduction</a></li><li><a href="rewrite_tech.html">Technical details</a></li><li><a href="rewrite_guide.html">Practical solutions to common -problems</a></li><li><a href="rewrite_guide_advanced.html">Practical solutions to -advanced problems</a></li></ul></div> +<div id="quickview"><h3>See also</h3><ul class="seealso"><li><a href="../urlmapping.html">Mapping URLs to the Filesystem</a></li><li><a href="http://wiki.apache.org/httpd/Rewrite">mod_rewrite +wiki</a></li><li><a href="../glossary.html">Glossary</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="documentation" id="documentation">Documentation</a></h2> @@ -80,17 +79,16 @@ advanced problems</a></li></ul></div> <li><a href="../mod/mod_rewrite.html">mod_rewrite reference documentation</a></li> <li><a href="rewrite_intro.html">Introduction</a></li> +<li><a href="rewrite_flags.html">Flags</a></li> <li><a href="rewrite_tech.html">Technical details</a></li> -<li><a href="rewrite_guide.html">Practical solutions to common -problems</a></li> -<li><a href="rewrite_guide_advanced.html">Practical solutions to -advanced problems</a></li> -<li><a href="../glossary.html">Glossary</a></li> +<li><a href="rewrite_guide.html">Rewrite Guide - useful examples</a></li> +<li><a href="rewrite_guide_advanced.html">Advanced Rewrite Guide - more +useful examples</a></li> </ul> </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/" title="English"> en </a></p> </div><div id="footer"> -<p class="apache">Copyright 2007 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> +<p class="apache">Copyright 2008 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> <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> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/rewrite_flags.html b/docs/manual/rewrite/rewrite_flags.html new file mode 100644 index 00000000..ac41b36d --- /dev/null +++ b/docs/manual/rewrite/rewrite_flags.html @@ -0,0 +1,5 @@ +# GENERATED FROM XML -- DO NOT EDIT + +URI: rewrite_flags.html.en +Content-Language: en +Content-type: text/html; charset=ISO-8859-1 diff --git a/docs/manual/rewrite/rewrite_flags.html.en b/docs/manual/rewrite/rewrite_flags.html.en new file mode 100644 index 00000000..7063cc57 --- /dev/null +++ b/docs/manual/rewrite/rewrite_flags.html.en @@ -0,0 +1,420 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!-- + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + This file is generated from xml source: DO NOT EDIT + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + --> +<title>Apache mod_rewrite Flags - Apache HTTP Server</title> +<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> +<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> +<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /> +<link href="../images/favicon.ico" rel="shortcut icon" /></head> +<body id="manual-page"><div id="page-header"> +<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> +<p class="apache">Apache HTTP Server Version 2.2</p> +<img alt="" src="../images/feather.gif" /></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div id="path"> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Flags</h1> +<div class="toplang"> +<p><span>Available Languages: </span><a href="../en/rewrite/rewrite_flags.html" title="English"> en </a></p> +</div> + +<p>This document discusses the flags which are available to the +<code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> directive, +providing detailed explanations and examples. This is not necessarily +a comprehensive list of all flags available, so be sure to also +consult the reference documentation.</p> +</div> +<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#introduction">Introduction</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#flags">The flags</a></li> +</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">Rewrite Guide - useful examples</a></li><li><a href="rewrite_guide_advanced.html">Advanced Rewrite Guide - +advanced useful examples</a></li></ul></div> +<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="introduction" id="introduction">Introduction</a></h2> +<p><code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>s can have +their behavior modified by one or more flags. Flags are included in +square brackets at the end of the rule, and multiple flags are separated +by commas.</p> +<div class="example"><p><code> +RewriteRule pattern target [Flag1,Flag2,Flag3] +</code></p></div> + +<p>The flags all have a short form, such as <code>CO</code>, as well as +a longer form, such as <code>cookie</code>. Some flags take one or more +arguments. Flags are not case sensitive.</p> + +</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="flags" id="flags">The flags</a></h2> + +<p>Each flag has a long and short form. While it is most common to use +the short form, it is recommended that you familiarize yourself with the +long form, so that you remember what each flag is supposed to do.</p> + +<p>Presented here are each of the available flags, along with an example +of how you might use them.</p> + +<h3><a name="flag_c" id="flag_c">C|chain</a></h3> +<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 +rule. That is, if the rule matches, then it is processed as usual and +control moves on to the next rule. However, if it does not match, then +the next rule, and any other rules that are chained together, will be +skipped.</p> + + + +<h3><a name="flag_co" id="flag_co">CO|cookie</a></h3> +<p>The [CO], or [cookie] flag, allows you to set a cookie when a +particular <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> +matches. The argument consists of three required fields and two optional +fields.</p> +<p>You must declare a name and value for the cookie to be set, and the +domain for which you wish the cookie to be valid. You may optionally set +the lifetime of the cookie, and the path for which it should be +returned.</p> +<p>By default, the lifetime of the cookie is the current browser +session.</p> +<p>By default, the path for which the cookie will be valid is "/" - that +is, the entire website.</p> +<p>Several examples are offered here:</p> + +<div class="example"><p><code> +RewriteEngine On<br /> +RewriteRule ^/index.html - [CO=frontdoor:yes:.apache.org:1440:/] +</code></p></div> + +<p>This rule doesn't rewrite the request (the "-" rewrite target tells +mod_rewrite to pass the request through unchanged) but sets a cookie +called 'frontdoor' to a value of 'yes'. The cookie is valid for any host +in the <code>.apache.org</code> domain. It will be set to expire in 1440 +minutes (24 hours) and will be returned for all URIs.</p> + + + +<h3><a name="flag_e" id="flag_e">E|env</a></h3> +<p>With the [E], or [env] flag, you can set the value of an environment +variable. Note that some environment variables may be set after the rule +is run, thus unsetting what you have set. See <a href="../env.html">the +Environment Variables document</a> for more details on how Environment +variables work.</p> + +<p>The following example sets an evironment variable called 'image' to a +value of '1' if the requested URI is an image file. Then, that +environment variable is used to exclude those requests from the access +log.</p> + +<div class="example"><p><code> +RewriteRule \.(png|gif|jpg) - [E=image:1]<br /> +CustomLog logs/access_log combined env=!image +</code></p></div> + +<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 +an example, not as a recommendation.</p> + + +<h3><a name="flag_f" id="flag_f">F|forbidden</a></h3> +<p>Using the [F] flag causes Apache to return a 403 Forbidden status +code to the client. While the same behavior can be accomplished using +the <code class="directive"><a href="../mod/mod_access.html#deny">Deny</a></code> directive, this +allows more flexibility in assigning a Forbidden status.</p> + +<p>The following rule will forbid <code>.exe</code> files from being +downloaded from your server.</p> + +<div class="example"><p><code> +RewriteRule \.exe - [F] +</code></p></div> + +<p>This example uses the "-" syntax for the rewrite target, which means +that the requested URI is not modified. There's no reason to rewrite to +another URI, if you're going to forbid the request.</p> + + + +<h3><a name="flag_g" id="flag_g">G|gone</a></h3> +<p>The [G] flag forces Apache to return a 410 Gone status with the +response. This indicates that a resource used to be available, but is no +longer available.</p> + +<p>As with the [F] flag, you will typically use the "-" syntax for the +rewrite target when using the [G] flag:</p> + +<div class="example"><p><code> +RewriteRule oldproduct - [G,NC] +</code></p></div> + + +<h3><a name="flag_h" id="flag_h">H|handler</a></h3> +<p>Forces the resulting request to be handled with the specified +handler. For example, one might use this to force all files without a +file extension to be parsed by the php handler:</p> + +<div class="example"><p><code> +RewriteRule !\. - [H=application/x-httpd-php] +</code></p></div> + +<p> +The regular expression above - <code>!\.</code> - will match any request +that does not contain the literal <code>.</code> character. +</p> + + +<h3><a name="flag_l" id="flag_l">L|last</a></h3> +<p>The [L] flag causes <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> to stop processing +the rule set. In most contexts, this means that if the rule matches, no +further rules will be processed.</p> + +<p>If you are using <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> in either +<code>.htaccess</code> files or in +<code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections, +it is important to have some understanding of how the rules are +processed. The simplified form of this is that once the rules have been +processed, the rewritten request is handed back to the URL parsing +engine to do what it may with it. It is possible that as the rewritten +request is handled, the <code>.htaccess</code> file or +<code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> section +may be encountered again, and thus the ruleset may be run again from the +start. Most commonly this will happen if one of the rules causes a +redirect - either internal or external - causing the request process to +start over.</p> + +<p>It is therefore important, if you are using <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> directives in one of these +context that you take explicit steps to avoid rules looping, and not +count solely on the [L] flag to terminate execution of a series of +rules, as shown below.</p> + +<p>The example given here will rewrite any request to +<code>index.php</code>, giving the original request as a query string +argument to <code>index.php</code>, however, if the request is already +for <code>index.php</code>, this rule will be skipped.</p> + +<div class="example"><p><code> +RewriteCond %{REQUEST_URI} !index\.php<br /> +RewriteRule ^(.*) index.php?req=$1 [L] +</code></p></div> + + +<h3><a name="flag_n" id="flag_n">N|next</a></h3> +<p> +The [N] flag causes the ruleset to start over again from the top. Use +with extreme caution, as it may result in loop. +</p> +<p> +The [Next] flag could be used, for example, if you wished to replace a +certain string or letter repeatedly in a request. The example shown here +will replace A with B everywhere in a request, and will continue doing +so until there are no more As to be replaced. +</p> + +<div class="example"><p><code> +RewriteRule (.*)A(.*) $1B$2 [N] +</code></p></div> + +<p>You can think of this as a <code>while</code> loop: While this +pattern still matches, perform this substitution.</p> + + + +<h3><a name="flag_nc" id="flag_nc">NC|nocase</a></h3> +<p>Use of the [NC] flag causes the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to be matched in a +case-insensitive manner. That is, it doesn't care whether letters appear +as upper-case or lower-case in the matched URI.</p> + +<p>In the example below, any request for an image file will be proxied +to your dedicated image server. The match is case-insensitive, so that +<code>.jpg</code> and <code>.JPG</code> files are both acceptable, for +example.</p> + +<div class="example"><p><code> +RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC] +</code></p></div> + + +<h3><a name="flag_ne" id="flag_ne">NE|noescape</a></h3> +<p>By default, special characters, such as <code>&</code> and +<code>?</code>, for example, will be converted to their hexcode +equivalent. Using the [NE] flag prevents that from happening. +</p> + +<div class="example"><p><code> +RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R] +</code></p></div> + +<p> +The above example will redirect <code>/anchor/xyz</code> to +<code>/bigpage.html#xyz</code>. Omitting the [NE] will result in the # +being converted to its hexcode equivalent, <code>%23</code>, which will +then result in a 404 Not Found error condition. +</p> + + + +<h3><a name="flag_ns" id="flag_ns">NS|nosubreq</a></h3> +<p>Use of the [NS] flag prevents the rule from being used on +subrequests. For example, a page which is included using an SSI (Server +Side Include) is a subrequest, and you may want to avoid rewrites +happening on those subrequests.</p> + +<p> +Images, javascript files, or css files, loaded as part of an HTML page, +are not subrequests - the browser requests them as separate HTTP +requests. +</p> + + +<h3><a name="flag_p" id="flag_p">P|proxy</a></h3> +<p>Use of the [P] flag causes the request to be handled by +<code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>, and handled via a proxy request. For +example, if you wanted all image requests to be handled by a back-end +image server, you might do something like the following:</p> + +<div class="example"><p><code> +RewriteRule (.*)\.(jpg|gif|png) http://images.example.com$1.$2 [P] +</code></p></div> + +<p>Use of the [P] flag implies [L] - that is, the request is immediatly +pushed through the proxy, and any following rules will not be +considered.</p> + + + +<h3><a name="flag_pt" id="flag_pt">PT|passthrough</a></h3> + +<p> +The target (or substitution string) in a RewriteRule is assumed to be a +file path, by default. The use of the [PT] flag causes it to be treated +as a URI instead. That is to say, the +use of the [PT] flag causes the result of the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to be passed back through +URL mapping, so that location-based mappings, such as <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>, for example, might have a chance to take +effect. +</p> + +<p> +If, for example, you have an +<code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> +for /icons, and have a <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> pointing there, you should +use the [PT] flag to ensure that the +<code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> is evaluated. +</p> + +<div class="example"><p><code> +Alias /icons /usr/local/apache/icons<br /> +RewriteRule /pics/(.+)\.jpg /icons/$1.gif [PT] +</code></p></div> + +<p> +Omission of the [PT] flag in this case will cause the Alias to be +ignored, resulting in a 'File not found' error being returned. +</p> + + + +<h3><a name="flag_qsa" id="flag_qsa">QSA|qsappend</a></h3> +<p> +When the replacement URI contains a query string, the default behavior +of <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> is to discard +the existing query string, and replace it with the newly generated one. +Using the [QSA] flag causes the query strings to be combined. +</p> + +<p>Consider the following rule:</p> + +<div class="example"><p><code> +RewriteRule /pages/(.+) /page.php?page=$1 [QSA] +</code></p></div> + +<p>With the [QSA] flag, a request for <code>/pages/123?one=two</code> will be +mapped to <code>/page.php?page=123&one=two</code>. Without the [QSA] +flag, that same request will be mapped to +<code>/page.php?page=123</code> - that is, the existing query string +will be discarded. +</p> + + +<h3><a name="flag_r" id="flag_r">R|redirect</a></h3> +<p> +Use of the [R] flag causes a HTTP redirect to be issued to the browser. +If a fully-qualified URL is specified (that is, including +<code>http://servername/</code>) then a redirect will be issued to that +location. Otherwise, the current servername will be used to generate the +URL sent with the redirect. +</p> + +<p> +A status code may be specified, in the range 300-399, with a 302 status +code being used by default if none is specified. +</p> + +<p> +You will almost always want to use [R] in conjunction with [L] (that is, +use [R,L]) because on its own, the [R] flag prepends +<code>http://thishost[:thisport]</code> to the URI, but then passes this +on to the next rule in the ruleset, which can often result in 'Invalid +URI in request' warnings. +</p> + + + +<h3><a name="flag_s" id="flag_s">S|skip</a></h3> +<p>The [S] flag is used to skip rules that you don't want to run. This +can be thought of as a <code>goto</code> statement in your rewrite +ruleset. In the following example, we only want to run the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> if the requested URI +doesn't correspond with an actual file.</p> + +<div class="example"><p><code> +# Is the request for a non-existent file? +RewriteCond %{REQUEST_FILENAME} !-f<br /> +RewriteCond %{REQUEST_FILENAME} !-d<br /> +# If so, skip these two RewriteRules +RewriteRule .? - [S=2]<br /> +<br /> +RewriteRule (.*\.gif) images.php?$1<br /> +RewriteRule (.*\.html) docs.php?$1 +</code></p></div> + +<p>This technique is useful because a <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> only applies to the +<code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> immediately +following it. Thus, if you want to make a <code>RewriteCond</code> apply +to several <code>RewriteRule</code>s, one possible technique is to +negate those conditions and use a [Skip] flag.</p> + + + +<h3><a name="flag_t" id="flag_t">T|type</a></h3> +<p>Sets the MIME type with which the resulting response will be +sent. This has the same effect as the <code class="directive"><a href="../mod/mod_mime.html#addtype">AddType</a></code> directive.</p> + +<p>For example, you might use the following technique to serve Perl +source code as plain text, if requested in a particular way:</p> + +<div class="example"><p><code> +# Serve .pl files as plain text +RewriteRule \.pl$ - [T=text/plain] +</code></p></div> + +<p>Or, perhaps, if you have a camera that produces jpeg images without +file extensions, you could force those images to be served with the +correct MIME type by virtue of their file names:</p> + +<div class="example"><p><code> +# Files with 'IMG' in the name are jpg images.<br /> +RewriteRule IMG - [T=image/jpg] +</code></p></div> + +<p>Please note that this is a trivial example, and could be better done +using <code class="directive"><a href="../mod/core.html#filesmatch"><FilesMatch></a></code> +instead. Always consider the alternate +solutions to a problem before resorting to rewrite, which will +invariably be a less efficient solution than the alternatives.</p> + + +</div></div> +<div class="bottomlang"> +<p><span>Available Languages: </span><a href="../en/rewrite/rewrite_flags.html" title="English"> en </a></p> +</div><div id="footer"> +<p class="apache">Copyright 2008 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> +<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> +</body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/rewrite_guide.html b/docs/manual/rewrite/rewrite_guide.html index 49f623e9..69c288c8 100644 --- a/docs/manual/rewrite/rewrite_guide.html +++ b/docs/manual/rewrite/rewrite_guide.html @@ -1,3 +1,5 @@ +# GENERATED FROM XML -- DO NOT EDIT + URI: rewrite_guide.html.en Content-Language: en Content-type: text/html; charset=ISO-8859-1 diff --git a/docs/manual/rewrite/rewrite_guide.html.en b/docs/manual/rewrite/rewrite_guide.html.en index 63fa1cee..54b7923c 100644 --- a/docs/manual/rewrite/rewrite_guide.html.en +++ b/docs/manual/rewrite/rewrite_guide.html.en @@ -14,9 +14,9 @@ <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> <p class="apache">Apache HTTP Server Version 2.2</p> <img alt="" src="../images/feather.gif" /></div> -<div class="up"><a href="./index.html"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> <div id="path"> -<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a></div><div id="page-content"><div id="preamble"><h1>URL Rewriting Guide</h1> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>URL Rewriting Guide</h1> <div class="toplang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_guide.html" title="English"> en </a></p> </div> @@ -26,7 +26,7 @@ <a href="../mod/mod_rewrite.html">reference documentation</a>. It describes how one can use Apache's <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> to solve typical URL-based problems with which webmasters are - commonony confronted. We give detailed descriptions on how to + commonly confronted. We give detailed descriptions on how to solve each problem by configuring URL rewriting rulesets.</p> <div class="warning">ATTENTION: Depending on your server configuration @@ -50,15 +50,19 @@ <li><img alt="" src="../images/down.gif" /> <a href="#uservhosts">Virtual User Hosts</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#redirecthome">Redirect Homedirs For Foreigners</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#redirectanchors">Redirecting Anchors</a></li> -<li><img alt="" src="../images/down.gif" /> Time-Dependent Rewriting</li> -<li><img alt="" src="../images/down.gif" /> Backward Compatibility for YYYY to XXXX migration</li> -<li><img alt="" src="../images/down.gif" /> <a href="#content">Content Handling</a></li> -<li><img alt="" src="../images/down.gif" /> <a href="#access">Access Restriction</a></li> -<li><img alt="" src="../images/down.gif" /> <a href="#other">Other</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#time-dependent">Time-Dependent Rewriting</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#backward-compatibility">Backward Compatibility for YYYY to XXXX migration</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#old-to-new">From Old to New (intern)</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#old-to-new-extern">From Old to New (extern)</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#static-to-dynamic">From Static to Dynamic</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#blocking-of-robots">Blocking of Robots</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#blocked-inline-images">Blocked Inline-Images</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#proxy-deny">Proxy Deny</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#external-rewriting">External Rewriting Engine</a></li> </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="rewrite_intro.html">mod_rewrite -introduction</a></li><li><a href="rewrite_guide_advanced.html">Practical solutions to -advanced problems</a></li><li><a href="rewrite_tech.html">Technical details</a></li></ul></div> +introduction</a></li><li><a href="rewrite_guide_advanced.html">Advanced Rewrite Guide - advanced +useful examples</a></li><li><a href="rewrite_tech.html">Technical details</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="canonicalurl" id="canonicalurl">Canonical URLs</a></h2> @@ -276,12 +280,12 @@ RewriteRule ^/~(.+) http://<strong>newserver</strong>/~$1 [R,L] <div class="example"><pre> RewriteEngine on -# first try to find it in custom/... +# first try to find it in dir1/... # ...and if found stop and be happy: RewriteCond /your/docroot/<strong>dir1</strong>/%{REQUEST_FILENAME} -f RewriteRule ^(.+) /your/docroot/<strong>dir1</strong>/$1 [L] -# second try to find it in pub/... +# second try to find it in dir2/... # ...and if found stop and be happy: RewriteCond /your/docroot/<strong>dir2</strong>/%{REQUEST_FILENAME} -f RewriteRule ^(.+) /your/docroot/<strong>dir2</strong>/$1 [L] @@ -418,7 +422,7 @@ RewriteRule ^(/~.+) http://www.somewhere.com/$1 [R,L] </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2>Time-Dependent Rewriting</h2> +<h2><a name="time-dependent" id="time-dependent">Time-Dependent Rewriting</a></h2> @@ -459,7 +463,7 @@ RewriteRule ^foo\.html$ foo.night.html </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2>Backward Compatibility for YYYY to XXXX migration</h2> +<h2><a name="backward-compatibility" id="backward-compatibility">Backward Compatibility for YYYY to XXXX migration</a></h2> @@ -502,11 +506,7 @@ RewriteRule ^(.*)$ $1.html </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2><a name="content" id="content">Content Handling</a></h2> - - - - <h3>From Old to New (intern)</h3> +<h2><a name="old-to-new" id="old-to-new">From Old to New (intern)</a></h2> @@ -535,9 +535,9 @@ RewriteRule ^<strong>foo</strong>\.html$ <strong>bar</strong>.html </dd> </dl> - - - <h3>From Old to New (extern)</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="old-to-new-extern" id="old-to-new-extern">From Old to New (extern)</a></h2> @@ -567,9 +567,9 @@ RewriteRule ^<strong>foo</strong>\.html$ <strong>bar</strong>.html [<strong </dd> </dl> - - - <h3>From Static to Dynamic</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="static-to-dynamic" id="static-to-dynamic">From Static to Dynamic</a></h2> @@ -587,7 +587,8 @@ RewriteRule ^<strong>foo</strong>\.html$ <strong>bar</strong>.html [<strong <dd> <p>We just rewrite the URL to the CGI-script and force the - correct MIME-type so it gets really run as a CGI-script. + handler to be <strong>cgi-script</strong> so that it is + executed as a CGI program. This way a request to <code>/~quux/foo.html</code> internally leads to the invocation of <code>/~quux/foo.cgi</code>.</p> @@ -595,19 +596,14 @@ RewriteRule ^<strong>foo</strong>\.html$ <strong>bar</strong>.html [<strong <div class="example"><pre> RewriteEngine on RewriteBase /~quux/ -RewriteRule ^foo\.<strong>html</strong>$ foo.<strong>cgi</strong> [T=<strong>application/x-httpd-cgi</strong>] +RewriteRule ^foo\.<strong>html</strong>$ foo.<strong>cgi</strong> [H=<strong>cgi-script</strong>] </pre></div> </dd> </dl> - -</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2><a name="access" id="access">Access Restriction</a></h2> - - - - <h3>Blocking of Robots</h3> +<h2><a name="blocking-of-robots" id="blocking-of-robots">Blocking of Robots</a></h2> @@ -643,9 +639,9 @@ RewriteRule ^<strong>/~quux/foo/arc/</strong>.+ - [<strong>F</strong>] </dd> </dl> - - - <h3>Blocked Inline-Images</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="blocked-inline-images" id="blocked-inline-images">Blocked Inline-Images</a></h2> @@ -681,9 +677,9 @@ RewriteRule <strong>^inlined-in-foo\.gif$</strong> - [F </dd> </dl> - - - <h3>Proxy Deny</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="proxy-deny" id="proxy-deny">Proxy Deny</a></h2> @@ -718,15 +714,9 @@ RewriteRule !^http://[^/.]\.mydomain.com.* - [F] </dd> </dl> - - - </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2><a name="other" id="other">Other</a></h2> - - - - <h3>External Rewriting Engine</h3> +<h2><a name="external-rewriting" id="external-rewriting">External Rewriting Engine</a></h2> @@ -778,12 +768,10 @@ while (<>) { </dd> </dl> - - - </div></div> + </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_guide.html" title="English"> en </a></p> </div><div id="footer"> -<p class="apache">Copyright 2007 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> +<p class="apache">Copyright 2008 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> <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> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/rewrite_guide_advanced.html b/docs/manual/rewrite/rewrite_guide_advanced.html index 07850dd6..d08ed10d 100644 --- a/docs/manual/rewrite/rewrite_guide_advanced.html +++ b/docs/manual/rewrite/rewrite_guide_advanced.html @@ -1,3 +1,5 @@ +# GENERATED FROM XML -- DO NOT EDIT + URI: rewrite_guide_advanced.html.en Content-Language: en Content-type: text/html; charset=ISO-8859-1 diff --git a/docs/manual/rewrite/rewrite_guide_advanced.html.en b/docs/manual/rewrite/rewrite_guide_advanced.html.en index 9ea476f0..1859b9b5 100644 --- a/docs/manual/rewrite/rewrite_guide_advanced.html.en +++ b/docs/manual/rewrite/rewrite_guide_advanced.html.en @@ -14,9 +14,9 @@ <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> <p class="apache">Apache HTTP Server Version 2.2</p> <img alt="" src="../images/feather.gif" /></div> -<div class="up"><a href="./index.html"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> <div id="path"> -<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a></div><div id="page-content"><div id="preamble"><h1>URL Rewriting Guide - Advanced topics</h1> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>URL Rewriting Guide - Advanced topics</h1> <div class="toplang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_guide_advanced.html" title="English"> en </a></p> </div> @@ -26,34 +26,45 @@ <a href="../mod/mod_rewrite.html">reference documentation</a>. It describes how one can use Apache's <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> to solve typical URL-based problems with which webmasters are - commonony confronted. We give detailed descriptions on how to + commonly confronted. We give detailed descriptions on how to solve each problem by configuring URL rewriting rulesets.</p> <div class="warning">ATTENTION: Depending on your server configuration - it may be necessary to slightly change the examples for your - situation, e.g. adding the <code>[PT]</code> flag when - additionally using <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> and + it may be necessary to adjust the examples for your + situation, e.g., adding the <code>[PT]</code> flag if + using <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> and <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code>, etc. Or rewriting a ruleset - to fit in <code>.htaccess</code> context instead + to work in <code>.htaccess</code> context instead of per-server context. Always try to understand what a - particular ruleset really does before you use it. This + particular ruleset really does before you use it; this avoids many problems.</div> </div> -<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#cluster">Webcluster through Homogeneous URL Layout</a></li> +<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#cluster">Web Cluster with Consistent URL Space</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#structuredhomedirs">Structured Homedirs</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#filereorg">Filesystem Reorganization</a></li> -<li><img alt="" src="../images/down.gif" /> <a href="#redirect404">Redirect Failing URLs To Other Webserver</a></li> -<li><img alt="" src="../images/down.gif" /> Archive Access Multiplexer</li> -<li><img alt="" src="../images/down.gif" /> <a href="#content">Content Handling</a></li> -<li><img alt="" src="../images/down.gif" /> <a href="#access">Access Restriction</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#redirect404">Redirect Failing URLs to Another Web Server</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#archive-access-multiplexer">Archive Access Multiplexer</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#browser-dependent-content">Browser Dependent Content</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#dynamic-mirror">Dynamic Mirror</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#reverse-dynamic-mirror">Reverse Dynamic Mirror</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#retrieve-missing-data">Retrieve Missing Data from Intranet</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#load-balancing">Load Balancing</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#new-mime-type">New MIME-type, New Service</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#on-the-fly-content">On-the-fly Content-Regeneration</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#autorefresh">Document With Autorefresh</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#mass-virtual-hosting">Mass Virtual Hosting</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#host-deny">Host Deny</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#proxy-deny">Proxy Deny</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#special-authentication">Special Authentication Variant</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#referer-deflector">Referer-based Deflector</a></li> </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="rewrite_intro.html">mod_rewrite -introduction</a></li><li><a href="rewrite_guide.html">Practical solutions to common -problems</a></li><li><a href="rewrite_tech.html">Technical details</a></li></ul></div> +introduction</a></li><li><a href="rewrite_guide.html">Rewrite Guide - useful +examples</a></li><li><a href="rewrite_tech.html">Technical details</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2><a name="cluster" id="cluster">Webcluster through Homogeneous URL Layout</a></h2> +<h2><a name="cluster" id="cluster">Web Cluster with Consistent URL Space</a></h2> @@ -62,23 +73,23 @@ problems</a></li><li><a href="rewrite_tech.html">Technical details</a></li></ul> <dd> <p>We want to create a homogeneous and consistent URL - layout over all WWW servers on a Intranet webcluster, i.e. - all URLs (per definition server local and thus server - dependent!) become actually server <em>independent</em>! - What we want is to give the WWW namespace a consistent - server-independent layout: no URL should have to include - any physically correct target server. The cluster itself - should drive us automatically to the physical target - host.</p> + layout across all WWW servers on an Intranet web cluster, i.e., + all URLs (by definition server-local and thus + server-dependent!) become server <em>independent</em>! + What we want is to give the WWW namespace a single consistent + layout: no URL should refer to + any particular target server. The cluster itself + should connect users automatically to a physical target + host as needed, invisibly.</p> </dd> <dt>Solution:</dt> <dd> - <p>First, the knowledge of the target servers come from - (distributed) external maps which contain information - where our users, groups and entities stay. The have the - form</p> + <p>First, the knowledge of the target servers comes from + (distributed) external maps which contain information on + where our users, groups, and entities reside. They have the + form:</p> <div class="example"><pre> user1 server_of_user1 @@ -88,7 +99,7 @@ user2 server_of_user2 <p>We put them into files <code>map.xxx-to-host</code>. Second we need to instruct all servers to redirect URLs - of the forms</p> + of the forms:</p> <div class="example"><pre> /u/user/anypath @@ -104,8 +115,8 @@ http://physical-host/g/group/anypath http://physical-host/e/entity/anypath </pre></div> - <p>when the URL is not locally valid to a server. The - following ruleset does this for us by the help of the map + <p>when any URL path need not be valid on every server. The + following ruleset does this for us with the help of the map files (assuming that server0 is a default server which will be used if a user has no entry in the map):</p> @@ -136,9 +147,9 @@ RewriteRule ^/([uge])/([^/]+)/([^.]+.+) /$1/$2/.www/$3\ <dt>Description:</dt> <dd> - <p>Some sites with thousands of users usually use a - structured homedir layout, i.e. each homedir is in a - subdirectory which begins for instance with the first + <p>Some sites with thousands of users use a + structured homedir layout, <em>i.e.</em> each homedir is in a + subdirectory which begins (for instance) with the first character of the username. So, <code>/~foo/anypath</code> is <code>/home/<strong>f</strong>/foo/.www/anypath</code> while <code>/~bar/anypath</code> is @@ -149,7 +160,7 @@ RewriteRule ^/([uge])/([^/]+)/([^.]+.+) /$1/$2/.www/$3\ <dd> <p>We use the following ruleset to expand the tilde URLs - into exactly the above layout.</p> + into the above layout.</p> <div class="example"><pre> RewriteEngine on @@ -175,7 +186,7 @@ RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</stro adjusted. Background: <strong><em>net.sw</em></strong> is my archive of freely available Unix software packages, which I started to collect in 1992. It is both my hobby - and job to to this, because while I'm studying computer + and job to do this, because while I'm studying computer science I have also worked for many years as a system and network administrator in my spare time. Every week I need some sort of software so I created a deep hierarchy of @@ -204,11 +215,11 @@ drwxrwxr-x 10 netsw users 512 Jul 9 14:08 X11/ the world via a nice Web interface. "Nice" means that I wanted to offer an interface where you can browse directly through the archive hierarchy. And "nice" means - that I didn't wanted to change anything inside this + that I didn't want to change anything inside this hierarchy - not even by putting some CGI scripts at the - top of it. Why? Because the above structure should be - later accessible via FTP as well, and I didn't want any - Web or CGI stuff to be there.</p> + top of it. Why? Because the above structure should later be + accessible via FTP as well, and I didn't want any + Web or CGI stuff mixed in there.</p> </dd> <dt>Solution:</dt> @@ -236,8 +247,8 @@ drwxr-xr-x 2 netsw users 512 Jul 8 23:47 netsw-img/ </pre></div> <p>The <code>DATA/</code> subdirectory holds the above - directory structure, i.e. the real - <strong><em>net.sw</em></strong> stuff and gets + directory structure, <em>i.e.</em> the real + <strong><em>net.sw</em></strong> stuff, and gets automatically updated via <code>rdist</code> from time to time. The second part of the problem remains: how to link these two structures together into one smooth-looking URL @@ -246,7 +257,7 @@ drwxr-xr-x 2 netsw users 512 Jul 8 23:47 netsw-img/ for the various URLs. Here is the solution: first I put the following into the per-directory configuration file in the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> - of the server to rewrite the announced URL + of the server to rewrite the public URL path <code>/net.sw/</code> to the internal path <code>/e/netsw</code>:</p> @@ -296,7 +307,7 @@ RewriteRule (.*) netsw-lsdir.cgi/$1 <ol> <li>Notice the <code>L</code> (last) flag and no - substitution field ('<code>-</code>') in the forth part</li> + substitution field ('<code>-</code>') in the fourth part</li> <li>Notice the <code>!</code> (not) character and the <code>C</code> (chain) flag at the first rule @@ -309,7 +320,7 @@ RewriteRule (.*) netsw-lsdir.cgi/$1 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2><a name="redirect404" id="redirect404">Redirect Failing URLs To Other Webserver</a></h2> +<h2><a name="redirect404" id="redirect404">Redirect Failing URLs to Another Web Server</a></h2> @@ -319,18 +330,18 @@ RewriteRule (.*) netsw-lsdir.cgi/$1 <dd> <p>A typical FAQ about URL rewriting is how to redirect failing requests on webserver A to webserver B. Usually - this is done via <code class="directive"><a href="../mod/core.html#errordocument">ErrorDocument</a></code> CGI-scripts in Perl, but + this is done via <code class="directive"><a href="../mod/core.html#errordocument">ErrorDocument</a></code> CGI scripts in Perl, but there is also a <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> solution. - But notice that this performs more poorly than using an + But note that this performs more poorly than using an <code class="directive"><a href="../mod/core.html#errordocument">ErrorDocument</a></code> - CGI-script!</p> + CGI script!</p> </dd> <dt>Solution:</dt> <dd> <p>The first solution has the best performance but less - flexibility, and is less error safe:</p> + flexibility, and is less safe:</p> <div class="example"><pre> RewriteEngine on @@ -341,7 +352,7 @@ RewriteRule ^(.+) http://<strong>webserverB</stron <p>The problem here is that this will only work for pages inside the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. While you can add more Conditions (for instance to also handle homedirs, etc.) - there is better variant:</p> + there is a better variant:</p> <div class="example"><pre> RewriteEngine on @@ -351,17 +362,17 @@ RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1 <p>This uses the URL look-ahead feature of <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. The result is that this will work for all types of URLs - and is a safe way. But it does a performance impact on - the webserver, because for every request there is one - more internal subrequest. So, if your webserver runs on a + and is safe. But it does have a performance impact on + the web server, because for every request there is one + more internal subrequest. So, if your web server runs on a powerful CPU, use this one. If it is a slow machine, use - the first approach or better a <code class="directive"><a href="../mod/core.html#errordocument">ErrorDocument</a></code> CGI-script.</p> + the first approach or better an <code class="directive"><a href="../mod/core.html#errordocument">ErrorDocument</a></code> CGI script.</p> </dd> </dl> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2>Archive Access Multiplexer</h2> +<h2><a name="archive-access-multiplexer" id="archive-access-multiplexer">Archive Access Multiplexer</a></h2> @@ -371,18 +382,18 @@ RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1 <dd> <p>Do you know the great CPAN (Comprehensive Perl Archive Network) under <a href="http://www.perl.com/CPAN">http://www.perl.com/CPAN</a>? - This does a redirect to one of several FTP servers around - the world which carry a CPAN mirror and is approximately - near the location of the requesting client. Actually this - can be called an FTP access multiplexing service. While - CPAN runs via CGI scripts, how can a similar approach - implemented via <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>?</p> + CPAN automatically redirects browsers to one of many FTP + servers around the world (generally one near the requesting + client); each server carries a full CPAN mirror. This is + effectively an FTP access multiplexing service. + CPAN runs via CGI scripts, but how could a similar approach + be implemented via <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>?</p> </dd> <dt>Solution:</dt> <dd> - <p>First we notice that from version 3.0.0 + <p>First we notice that as of version 3.0.0, <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> can also use the "<code>ftp:</code>" scheme on redirects. And second, the location approximation can be done by a @@ -414,11 +425,7 @@ com ftp://ftp.cxan.com/CxAN/ </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2><a name="content" id="content">Content Handling</a></h2> - - - - <h3>Browser Dependent Content</h3> +<h2><a name="browser-dependent-content" id="browser-dependent-content">Browser Dependent Content</a></h2> @@ -428,9 +435,9 @@ com ftp://ftp.cxan.com/CxAN/ <dd> <p>At least for important top-level pages it is sometimes necessary to provide the optimum of browser dependent - content, i.e. one has to provide a maximum version for the - latest Netscape variants, a minimum version for the Lynx - browsers and a average feature version for all others.</p> + content, i.e., one has to provide one version for + current browsers, a different version for the Lynx and text-mode + browsers, and another for other browsers.</p> </dd> <dt>Solution:</dt> @@ -438,14 +445,14 @@ com ftp://ftp.cxan.com/CxAN/ <dd> <p>We cannot use content negotiation because the browsers do not provide their type in that form. Instead we have to - act on the HTTP header "User-Agent". The following condig + act on the HTTP header "User-Agent". The following config does the following: If the HTTP header "User-Agent" begins with "Mozilla/3", the page <code>foo.html</code> - is rewritten to <code>foo.NS.html</code> and and the + is rewritten to <code>foo.NS.html</code> and the rewriting stops. If the browser is "Lynx" or "Mozilla" of - version 1 or 2 the URL becomes <code>foo.20.html</code>. + version 1 or 2, the URL becomes <code>foo.20.html</code>. All other browsers receive page <code>foo.32.html</code>. - This is done by the following ruleset:</p> + This is done with the following ruleset:</p> <div class="example"><pre> RewriteCond %{HTTP_USER_AGENT} ^<strong>Mozilla/3</strong>.* @@ -460,9 +467,9 @@ RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L </dd> </dl> - - - <h3>Dynamic Mirror</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="dynamic-mirror" id="dynamic-mirror">Dynamic Mirror</a></h2> @@ -470,25 +477,25 @@ RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L <dt>Description:</dt> <dd> - <p>Assume there are nice webpages on remote hosts we want + <p>Assume there are nice web pages on remote hosts we want to bring into our namespace. For FTP servers we would use the <code>mirror</code> program which actually maintains an explicit up-to-date copy of the remote data on the local - machine. For a webserver we could use the program - <code>webcopy</code> which acts similar via HTTP. But both - techniques have one major drawback: The local copy is - always just as up-to-date as often we run the program. It - would be much better if the mirror is not a static one we + machine. For a web server we could use the program + <code>webcopy</code> which runs via HTTP. But both + techniques have a major drawback: The local copy is + always only as up-to-date as the last time we ran the program. It + would be much better if the mirror was not a static one we have to establish explicitly. Instead we want a dynamic - mirror with data which gets updated automatically when - there is need (updated data on the remote host).</p> + mirror with data which gets updated automatically + as needed on the remote host(s).</p> </dd> <dt>Solution:</dt> <dd> - <p>To provide this feature we map the remote webpage or even - the complete remote webarea to our namespace by the use + <p>To provide this feature we map the remote web page or even + the complete remote web area to our namespace by the use of the <dfn>Proxy Throughput</dfn> feature (flag <code>[P]</code>):</p> @@ -506,9 +513,9 @@ RewriteRule ^<strong>usa-news\.html</strong>$ <strong>http://www.quux-corp. </dd> </dl> - - - <h3>Reverse Dynamic Mirror</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="reverse-dynamic-mirror" id="reverse-dynamic-mirror">Reverse Dynamic Mirror</a></h2> @@ -528,9 +535,9 @@ RewriteRule ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1 </dd> </dl> - - - <h3>Retrieve Missing Data from Intranet</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="retrieve-missing-data" id="retrieve-missing-data">Retrieve Missing Data from Intranet</a></h2> @@ -539,22 +546,22 @@ RewriteRule ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1 <dd> <p>This is a tricky way of virtually running a corporate - (external) Internet webserver + (external) Internet web server (<code>www.quux-corp.dom</code>), while actually keeping - and maintaining its data on a (internal) Intranet webserver + and maintaining its data on an (internal) Intranet web server (<code>www2.quux-corp.dom</code>) which is protected by a - firewall. The trick is that on the external webserver we - retrieve the requested data on-the-fly from the internal + firewall. The trick is that the external web server retrieves + the requested data on-the-fly from the internal one.</p> </dd> <dt>Solution:</dt> <dd> - <p>First, we have to make sure that our firewall still - protects the internal webserver and that only the - external webserver is allowed to retrieve data from it. - For a packet-filtering firewall we could for instance + <p>First, we must make sure that our firewall still + protects the internal web server and only the + external web server is allowed to retrieve data from it. + On a packet-filtering firewall, for instance, we could configure a firewall ruleset like the following:</p> <div class="example"><pre> @@ -576,9 +583,9 @@ RewriteRule ^/home/([^/]+)/.www/?(.*) http://<strong>www2</strong>.quux-corp.dom </dd> </dl> - - - <h3>Load Balancing</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="load-balancing" id="load-balancing">Load Balancing</a></h2> @@ -587,25 +594,25 @@ RewriteRule ^/home/([^/]+)/.www/?(.*) http://<strong>www2</strong>.quux-corp.dom <dd> <p>Suppose we want to load balance the traffic to - <code>www.foo.com</code> over <code>www[0-5].foo.com</code> + <code>www.example.com</code> over <code>www[0-5].example.com</code> (a total of 6 servers). How can this be done?</p> </dd> <dt>Solution:</dt> <dd> - <p>There are a lot of possible solutions for this problem. - We will discuss first a commonly known DNS-based variant - and then the special one with <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>:</p> + <p>There are many possible solutions for this problem. + We will first discuss a common DNS-based method, + and then one based on <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>:</p> <ol> <li> <strong>DNS Round-Robin</strong> <p>The simplest method for load-balancing is to use - the DNS round-robin feature of <code>BIND</code>. - Here you just configure <code>www[0-9].foo.com</code> - as usual in your DNS with A(address) records, e.g.</p> + DNS round-robin. + Here you just configure <code>www[0-9].example.com</code> + as usual in your DNS with A (address) records, e.g.,</p> <div class="example"><pre> www0 IN A 1.2.3.1 @@ -616,7 +623,7 @@ www4 IN A 1.2.3.5 www5 IN A 1.2.3.6 </pre></div> - <p>Then you additionally add the following entry:</p> + <p>Then you additionally add the following entries:</p> <div class="example"><pre> www IN A 1.2.3.1 @@ -626,19 +633,21 @@ www IN A 1.2.3.4 www IN A 1.2.3.5 </pre></div> - <p>Now when <code>www.foo.com</code> gets + <p>Now when <code>www.example.com</code> gets resolved, <code>BIND</code> gives out <code>www0-www5</code> - - but in a slightly permutated/rotated order every time. + - but in a permutated (rotated) order every time. This way the clients are spread over the various - servers. But notice that this not a perfect load - balancing scheme, because DNS resolve information - gets cached by the other nameservers on the net, so - once a client has resolved <code>www.foo.com</code> - to a particular <code>wwwN.foo.com</code>, all - subsequent requests also go to this particular name - <code>wwwN.foo.com</code>. But the final result is - ok, because the total sum of the requests are really - spread over the various webservers.</p> + servers. But notice that this is not a perfect load + balancing scheme, because DNS resolutions are + cached by clients and other nameservers, so + once a client has resolved <code>www.example.com</code> + to a particular <code>wwwN.example.com</code>, all its + subsequent requests will continue to go to the same + IP (and thus a single server), rather than being + distributed across the other available servers. But the + overall result is + okay because the requests are collectively + spread over the various web servers.</p> </li> <li> @@ -648,8 +657,8 @@ www IN A 1.2.3.5 load-balancing is to use the program <code>lbnamed</code> which can be found at <a href="http://www.stanford.edu/~schemers/docs/lbnamed/lbnamed.html"> http://www.stanford.edu/~schemers/docs/lbnamed/lbnamed.html</a>. - It is a Perl 5 program in conjunction with auxilliary - tools which provides a real load-balancing for + It is a Perl 5 program which, in conjunction with auxilliary + tools, provides real load-balancing via DNS.</p> </li> @@ -658,17 +667,17 @@ www IN A 1.2.3.5 <p>In this variant we use <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> and its proxy throughput feature. First we dedicate - <code>www0.foo.com</code> to be actually - <code>www.foo.com</code> by using a single</p> + <code>www0.example.com</code> to be actually + <code>www.example.com</code> by using a single</p> <div class="example"><pre> -www IN CNAME www0.foo.com. +www IN CNAME www0.example.com. </pre></div> <p>entry in the DNS. Then we convert - <code>www0.foo.com</code> to a proxy-only server, - i.e. we configure this machine so all arriving URLs - are just pushed through the internal proxy to one of + <code>www0.example.com</code> to a proxy-only server, + i.e., we configure this machine so all arriving URLs + are simply passed through its internal proxy to one of the 5 other servers (<code>www1-www5</code>). To accomplish this we first establish a ruleset which contacts a load balancing script <code>lb.pl</code> @@ -706,30 +715,34 @@ while (<STDIN>) { </pre></div> <div class="note">A last notice: Why is this useful? Seems like - <code>www0.foo.com</code> still is overloaded? The + <code>www0.example.com</code> still is overloaded? The answer is yes, it is overloaded, but with plain proxy throughput requests, only! All SSI, CGI, ePerl, etc. - processing is completely done on the other machines. - This is the essential point.</div> + processing is handled done on the other machines. + For a complicated site, this may work well. The biggest + risk here is that www0 is now a single point of failure -- + if it crashes, the other servers are inaccessible.</div> </li> <li> - <strong>Hardware/TCP Round-Robin</strong> - - <p>There is a hardware solution available, too. Cisco - has a beast called LocalDirector which does a load - balancing at the TCP/IP level. Actually this is some - sort of a circuit level gateway in front of a - webcluster. If you have enough money and really need - a solution with high performance, use this one.</p> + <strong>Dedicated Load Balancers</strong> + + <p>There are more sophisticated solutions, as well. Cisco, + F5, and several other companies sell hardware load + balancers (typically used in pairs for redundancy), which + offer sophisticated load balancing and auto-failover + features. There are software packages which offer similar + features on commodity hardware, as well. If you have + enough money or need, check these out. The <a href="http://vegan.net/lb/">lb-l mailing list</a> is a + good place to research.</p> </li> </ol> </dd> </dl> - - - <h3>New MIME-type, New Service</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="new-mime-type" id="new-mime-type">New MIME-type, New Service</a></h2> @@ -737,8 +750,8 @@ while (<STDIN>) { <dt>Description:</dt> <dd> - <p>On the net there are a lot of nifty CGI programs. But - their usage is usually boring, so a lot of webmaster + <p>On the net there are many nifty CGI programs. But + their usage is usually boring, so a lot of webmasters don't use them. Even Apache's Action handler feature for MIME-types is only appropriate when the CGI programs don't need special URLs (actually <code>PATH_INFO</code> @@ -746,10 +759,10 @@ while (<STDIN>) { let us configure a new file type with extension <code>.scgi</code> (for secure CGI) which will be processed by the popular <code>cgiwrap</code> program. The problem - here is that for instance we use a Homogeneous URL Layout - (see above) a file inside the user homedirs has the URL - <code>/u/user/foo/bar.scgi</code>. But - <code>cgiwrap</code> needs the URL in the form + here is that for instance if we use a Homogeneous URL Layout + (see above) a file inside the user homedirs might have a URL + like <code>/u/user/foo/bar.scgi</code>, but + <code>cgiwrap</code> needs URLs in the form <code>/~user/foo/bar.scgi/</code>. The following rule solves the problem:</p> @@ -760,12 +773,12 @@ RewriteRule ^/[uge]/<strong>([^/]+)</strong>/\.www/(.+)\.scgi(.*) ... <p>Or assume we have some more nifty programs: <code>wwwlog</code> (which displays the - <code>access.log</code> for a URL subtree and + <code>access.log</code> for a URL subtree) and <code>wwwidx</code> (which runs Glimpse on a URL subtree). We have to provide the URL area to these - programs so they know on which area they have to act on. - But usually this ugly, because they are all the times - still requested from that areas, i.e. typically we would + programs so they know which area they are really working with. + But usually this is complicated, because they may still be + requested by the alternate URL form, i.e., typically we would run the <code>swwidx</code> program from within <code>/u/user/foo/</code> via hyperlink to</p> @@ -773,10 +786,10 @@ RewriteRule ^/[uge]/<strong>([^/]+)</strong>/\.www/(.+)\.scgi(.*) ... /internal/cgi/user/swwidx?i=/u/user/foo/ </pre></div> - <p>which is ugly. Because we have to hard-code + <p>which is ugly, because we have to hard-code <strong>both</strong> the location of the area <strong>and</strong> the location of the CGI inside the - hyperlink. When we have to reorganize the area, we spend a + hyperlink. When we have to reorganize, we spend a lot of time changing the various hyperlinks.</p> </dd> @@ -811,9 +824,9 @@ HREF="*" </dd> </dl> - - - <h3>On-the-fly Content-Regeneration</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="on-the-fly-content" id="on-the-fly-content">On-the-fly Content-Regeneration</a></h2> @@ -822,12 +835,12 @@ HREF="*" <dd> <p>Here comes a really esoteric feature: Dynamically - generated but statically served pages, i.e. pages should be + generated but statically served pages, i.e., pages should be delivered as pure static pages (read from the filesystem and just passed through), but they have to be generated - dynamically by the webserver if missing. This way you can - have CGI-generated pages which are statically served unless - one (or a cronjob) removes the static contents. Then the + dynamically by the web server if missing. This way you can + have CGI-generated pages which are statically served unless an + admin (or a <code>cron</code> job) removes the static contents. Then the contents gets refreshed.</p> </dd> @@ -841,22 +854,22 @@ RewriteCond %{REQUEST_FILENAME} <strong>!-s</strong> RewriteRule ^page\.<strong>html</strong>$ page.<strong>cgi</strong> [T=application/x-httpd-cgi,L] </pre></div> - <p>Here a request to <code>page.html</code> leads to a + <p>Here a request for <code>page.html</code> leads to an internal run of a corresponding <code>page.cgi</code> if - <code>page.html</code> is still missing or has filesize + <code>page.html</code> is missing or has filesize null. The trick here is that <code>page.cgi</code> is a - usual CGI script which (additionally to its <code>STDOUT</code>) + CGI script which (additionally to its <code>STDOUT</code>) writes its output to the file <code>page.html</code>. - Once it was run, the server sends out the data of + Once it has completed, the server sends out <code>page.html</code>. When the webmaster wants to force - a refresh the contents, he just removes - <code>page.html</code> (usually done by a cronjob).</p> + a refresh of the contents, he just removes + <code>page.html</code> (typically from <code>cron</code>).</p> </dd> </dl> - - - <h3>Document With Autorefresh</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="autorefresh" id="autorefresh">Document With Autorefresh</a></h2> @@ -864,9 +877,9 @@ RewriteRule ^page\.<strong>html</strong>$ page.<strong>cgi</strong> [ <dt>Description:</dt> <dd> - <p>Wouldn't it be nice while creating a complex webpage if - the webbrowser would automatically refresh the page every - time we write a new version from within our editor? + <p>Wouldn't it be nice, while creating a complex web page, if + the web browser would automatically refresh the page every + time we save a new version from within our editor? Impossible?</p> </dd> @@ -874,10 +887,10 @@ RewriteRule ^page\.<strong>html</strong>$ page.<strong>cgi</strong> [ <dd> <p>No! We just combine the MIME multipart feature, the - webserver NPH feature and the URL manipulation power of + web server NPH feature, and the URL manipulation power of <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. First, we establish a new URL feature: Adding just <code>:refresh</code> to any - URL causes this to be refreshed every time it gets + URL causes the 'page' to be refreshed every time it is updated on the filesystem.</p> <div class="example"><pre> @@ -1006,9 +1019,9 @@ exit(0); </dd> </dl> - - - <h3>Mass Virtual Hosting</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="mass-virtual-hosting" id="mass-virtual-hosting">Mass Virtual Hosting</a></h2> @@ -1017,18 +1030,17 @@ exit(0); <dd> <p>The <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> feature of Apache is nice - and works great when you just have a few dozens + and works great when you just have a few dozen virtual hosts. But when you are an ISP and have hundreds of - virtual hosts to provide this feature is not the best - choice.</p> + virtual hosts, this feature is suboptimal.</p> </dd> <dt>Solution:</dt> <dd> - <p>To provide this feature we map the remote webpage or even - the complete remote webarea to our namespace by the use - of the <dfn>Proxy Throughput</dfn> feature (flag <code>[P]</code>):</p> + <p>To provide this feature we map the remote web page or even + the complete remote web area to our namespace using the + <dfn>Proxy Throughput</dfn> feature (flag <code>[P]</code>):</p> <div class="example"><pre> ## @@ -1085,22 +1097,16 @@ RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$ RewriteCond ${vhost:%1} ^(/.*)$ # # 5. finally we can map the URL to its docroot location -# and remember the virtual host for logging puposes +# and remember the virtual host for logging purposes RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}] : </pre></div> </dd> </dl> - - - </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> -<h2><a name="access" id="access">Access Restriction</a></h2> - - - - <h3>Host Deny</h3> +<h2><a name="host-deny" id="host-deny">Host Deny</a></h2> @@ -1153,9 +1159,9 @@ bsdti1.sdm.de - </dd> </dl> - - - <h3>Proxy Deny</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="proxy-deny" id="proxy-deny">Proxy Deny</a></h2> @@ -1172,7 +1178,7 @@ bsdti1.sdm.de - <dd> <p>We first have to make sure <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> is below(!) <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code> in the Configuration - file when compiling the Apache webserver. This way it gets + file when compiling the Apache web server. This way it gets called <em>before</em> <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>. Then we configure the following for a host-dependent deny...</p> @@ -1190,9 +1196,9 @@ RewriteRule !^http://[^/.]\.mydomain.com.* - [F] </dd> </dl> - - - <h3>Special Authentication Variant</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="special-authentication" id="special-authentication">Special Authentication Variant</a></h2> @@ -1200,11 +1206,11 @@ RewriteRule !^http://[^/.]\.mydomain.com.* - [F] <dt>Description:</dt> <dd> - <p>Sometimes a very special authentication is needed, for - instance a authentication which checks for a set of + <p>Sometimes very special authentication is needed, for + instance authentication which checks for a set of explicitly configured users. Only these should receive access and without explicit prompting (which would occur - when using the Basic Auth via <code class="module"><a href="../mod/mod_auth.html">mod_auth</a></code>).</p> + when using Basic Auth via <code class="module"><a href="../mod/mod_auth_basic.html">mod_auth_basic</a></code>).</p> </dd> <dt>Solution:</dt> @@ -1222,9 +1228,9 @@ RewriteRule ^/~quux/only-for-friends/ - [F] </dd> </dl> - - - <h3>Referer-based Deflector</h3> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> +<div class="section"> +<h2><a name="referer-deflector" id="referer-deflector">Referer-based Deflector</a></h2> @@ -1274,12 +1280,10 @@ http://www.badguys.com/bad/index3.html http://somewhere.com/ </dd> </dl> - - - </div></div> + </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_guide_advanced.html" title="English"> en </a></p> </div><div id="footer"> -<p class="apache">Copyright 2007 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> +<p class="apache">Copyright 2008 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> <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> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/rewrite_intro.html b/docs/manual/rewrite/rewrite_intro.html index 607f1c18..e6e697d2 100644 --- a/docs/manual/rewrite/rewrite_intro.html +++ b/docs/manual/rewrite/rewrite_intro.html @@ -1,3 +1,5 @@ +# GENERATED FROM XML -- DO NOT EDIT + URI: rewrite_intro.html.en Content-Language: en Content-type: text/html; charset=ISO-8859-1 diff --git a/docs/manual/rewrite/rewrite_intro.html.en b/docs/manual/rewrite/rewrite_intro.html.en index e96dd216..e80d4441 100644 --- a/docs/manual/rewrite/rewrite_intro.html.en +++ b/docs/manual/rewrite/rewrite_intro.html.en @@ -14,9 +14,9 @@ <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> <p class="apache">Apache HTTP Server Version 2.2</p> <img alt="" src="../images/feather.gif" /></div> -<div class="up"><a href="./index.html"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> <div id="path"> -<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Introduction</h1> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Introduction</h1> <div class="toplang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_intro.html" title="English"> en </a></p> </div> @@ -35,7 +35,6 @@ but this doc should help the beginner get their feet wet. <li><img alt="" src="../images/down.gif" /> <a href="#rewritecond">Rewrite conditions</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#rewritemap">Rewrite maps</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#htaccess">.htaccess files</a></li> -<li><img alt="" src="../images/down.gif" /> <a href="#EnvVar">Environment Variables</a></li> </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 problems</a></li><li><a href="rewrite_guide_advanced.html">Practical solutions to @@ -53,6 +52,19 @@ using them without actually understanding what they do.</p> <p>This document attempts to give sufficient background so that what follows is understood, rather than just copied blindly. </p> + +<p>Remember that many common URL-manipulation tasks don't require the +full power and complexity of <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. For simple +tasks, see <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> and the documentation +on <a href="../urlmapping.html">mapping URLs to the +filesystem</a>.</p> + +<p>Finally, before proceeding, be sure to configure +the <code class="directive"><a href="../mod/mod_rewrite.html#rewritelog">RewriteLog</a></code>. Although +this log file can give an overwhelming amount of information, it is +indispensable in debugging problems with <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> +configuration, since it will tell you exactly how each rule is +processed.</p> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="regex" id="regex">Regular Expressions</a></h2> @@ -85,7 +97,7 @@ well as write your own.</p> <th>Example</th> </tr> -<tr><td><code>.</code></td><td>Matches any +<tr><td><code>.</code></td><td>Matches any single character</td><td><code>c.t</code> will match <code>cat</code>, <code>cot</code>, <code>cut</code>, etc.</td></tr> <tr><td><code>+</code></td><td>Repeats the previous match one or more @@ -94,10 +106,9 @@ times</td><td><code>a+</code> matches <code>a</code>, <code>aa</code>, <tr><td><code>*</code></td><td>Repeats the previous match zero or more times.</td><td><code>a*</code> matches all the same things <code>a+</code> matches, but will also match an empty string.</td></tr> -<tr><td><code>?</code></td><td>Makes the match optional.</td><td /></tr> -<tr><td><code>.</code></td><td>Matches any -character</td><td><code>colou?r</code> will match <code>color</code> and -<code>colour</code>.</td></tr> +<tr><td><code>?</code></td><td>Makes the match optional.</td><td> +<code>colou?r</code> will match <code>color</code> and <code>colour</code>.</td> +</tr> <tr><td><code>^</code></td><td>Called an anchor, matches the beginning of the string</td><td><code>^a</code> matches a string that begins with <code>a</code></td></tr> @@ -111,11 +122,14 @@ For more on backreferences see <a href="#InternalBackRefs">below</a>.</td></tr> <tr><td><code>[ ]</code></td><td>A character class - matches one of the characters</td><td><code>c[uoa]t</code> matches <code>cut</code>, <code>cot</code> or <code>cat</code>.</td></tr> -<tr><td><code>!</code></td><td>Not</td><td>Negates a match - that is, -ensures that it does not match.</td></tr> - +<tr><td><code>[^ ]</code></td><td>Negative character class - matches any character not specified</td><td><code>c[^/]t</code> matches <code>cat</code> or <code>c=t</code> but not <code>c/t</code></td></tr> </table> +<p>In <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> the <code>!</code> character can be +used before a regular expression to negate it. This is, a string will +be considered to have matched only if it does not match the rest of +the expression.</p> + <h3><a name="InternalBackRefs" id="InternalBackRefs">Regex Back-Reference Availability</a></h3> @@ -138,59 +152,161 @@ ensures that it does not match.</td></tr> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="rewriterule" id="rewriterule">RewriteRule basics</a></h2> -<p> -Basic anatomy of a RewriteRule, with exhaustively annotated simple -examples. -</p> +<p>A <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> consists +of three arguments separated by spaces. The arguments are</p> +<ol> +<li><var>Pattern</var>: which incoming URLs should be affected by the rule;</li> +<li><var>Substitution</var>: where should the matching requests be sent;</li> +<li><var>[flags]</var>: options affecting the rewritten request.</li> +</ol> + +<p>The <var>Pattern</var> is always a <a href="#regex">regular +expression</a> matched against the URL-Path of the incoming request +(the part after the hostname but before any question mark indicating +the beginning of a query string).</p> + +<p>The <var>Substitution</var> can itself be one of three things:</p> + +<dl> +<dt>A full filesystem path to a resource</dt> +<dd> +<div class="example"><p><code> +RewriteRule ^/games.* /usr/local/games/web +</code></p></div> +<p>This maps a request to an arbitrary location on your filesystem, much +like the <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> directive.</p> +</dd> + +<dt>A web-path to a resource</dt> +<dd> +<div class="example"><p><code> +RewriteRule ^/foo$ /bar +</code></p></div> +<p>If <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> is set +to <code>/usr/local/apache2/htdocs</code>, then this directive would +map requests for <code>http://example.com/foo</code> to the +path <code>/usr/local/apache2/htdocs/bar</code>.</p> +</dd> + +<dt>An absolute URL</dt> +<dd> +<div class="example"><p><code> +RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R] +</code></p></div> +<p>This tells the client to make a new request for the specified URL.</p> +</dd> +</dl> + +<p>The <var>Substitution</var> can also +contain <em>back-references</em> to parts of the incoming URL-path +matched by the <var>Pattern</var>. Consider the following:</p> +<div class="example"><p><code> +RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1 +</code></p></div> +<p>The variable <code>$1</code> will be replaced with whatever text +was matched by the expression inside the parenthesis in +the <var>Pattern</var>. For example, a request +for <code>http://example.com/product/r14df/view</code> will be mapped +to the path <code>/var/web/productdb/r14df</code>.</p> + +<p>If there is more than one expression in parenthesis, they are +available in order in the +variables <code>$1</code>, <code>$2</code>, <code>$3</code>, and so +on.</p> + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="flags" id="flags">Rewrite Flags</a></h2> -<p>Discussion of the flags to RewriteRule, and when and why one might -use them.</p> +<p>The behavior of a <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> can be modified by the +application of one or more flags to the end of the rule. For example, the +matching behavior of a rule can be made case-insensitive by the +application of the <code>[NC]</code> flag: +</p> +<div class="example"><p><code> +RewriteRule ^puppy.html smalldog.html [NC] +</code></p></div> + +<p>For more details on the available flags, their meanings, and +examples, see the <a href="rewrite_flags.html">Rewrite Flags</a> document.</p> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="rewritecond" id="rewritecond">Rewrite conditions</a></h2> -<p>Discussion of RewriteCond, looping, and other related concepts. -</p> +<p>One or more <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> +directives can be used to restrict the types of requests that will be +subject to the +following <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>. The +first argument is a variable describing a characteristic of the +request, the second argument is a <a href="#regex">regular +expression</a> that must match the variable, and a third optional +argument is a list of flags that modify how the match is evaluated.</p> + +<p>For example, to send all requests from a particular IP range to a +different server, you could use:</p> +<div class="example"><p><code> +RewriteCond %{REMOTE_ADDR} ^10\.2\.<br /> +RewriteRule (.*) http://intranet.example.com$1 +</code></p></div> + +<p>When more than +one <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> is +specified, they must all match for +the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to be +applied. For example, to deny requests that contain the word "hack" in +their query string, except if they also contain a cookie containing +the word "go", you could use:</p> +<div class="example"><p><code> +RewriteCond %{QUERY_STRING} hack<br /> +RewriteCond %{HTTP_COOKIE} !go<br /> +RewriteRule .* - [F] +</code></p></div> +<p>Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".</p> + +<p>Matches in the regular expressions contained in +the <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>s can be +used as part of the <var>Substitution</var> in +the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> using the +variables <code>%1</code>, <code>%2</code>, etc. For example, this +will direct the request to a different directory depending on the +hostname used to access the site:</p> +<div class="example"><p><code> +RewriteCond %{HTTP_HOST} (.*)<br /> +RewriteRule ^/(.*) /sites/%1/$1 +</code></p></div> +<p>If the request was for <code>http://example.com/foo/bar</code>, +then <code>%1</code> would contain <code>example.com</code> +and <code>$1</code> would contain <code>foo/bar</code>.</p> + + + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="rewritemap" id="rewritemap">Rewrite maps</a></h2> -<p>Discussion of RewriteMap, including simple, but heavily annotated, -examples.</p> +<p>See <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code>.</p> </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="htaccess" id="htaccess">.htaccess files</a></h2> -<p>Discussion of the differences between rewrite rules in httpd.conf and -in .htaccess files.</p> -</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> -<div class="section"> -<h2><a name="EnvVar" id="EnvVar">Environment Variables</a></h2> - -<p>This module keeps track of two additional (non-standard) -CGI/SSI environment variables named <code>SCRIPT_URL</code> -and <code>SCRIPT_URI</code>. These contain the -<em>logical</em> Web-view to the current resource, while the -standard CGI/SSI variables <code>SCRIPT_NAME</code> and -<code>SCRIPT_FILENAME</code> contain the <em>physical</em> -System-view. </p> - -<p>Notice: These variables hold the URI/URL <em>as they were -initially requested</em>, <em>i.e.</em>, <em>before</em> any -rewriting. This is important because the rewriting process is -primarily used to rewrite logical URLs to physical -pathnames.</p> - -<div class="example"><h3>Example</h3><pre> -SCRIPT_NAME=/sw/lib/w3s/tree/global/u/rse/.www/index.html -SCRIPT_FILENAME=/u/rse/.www/index.html -SCRIPT_URL=/u/rse/ -SCRIPT_URI=http://en1.engelschall.com/u/rse/ -</pre></div> + +<p>Rewriting is typically configured in the main server configuration +setting (outside any <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> section) or +inside <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> +containers. This is the easiest way to do rewriting and is +recommended. It is possible, however, to do rewriting +inside <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> +sections or <a href="../howto/htaccess.html"><code>.htaccess</code> +files</a> at the expense of some additional complexity. This technique +is called per-directory rewrites.</p> + +<p>The main difference with per-server rewrites is that the path +prefix of the directory containing the <code>.htaccess</code> file is +stripped before matching in +the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>. In addition, the <code class="directive"><a href="../mod/mod_rewrite.html#rewritebase">RewriteBase</a></code> should be used to assure the request is properly mapped.</p> </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_intro.html" title="English"> en </a></p> </div><div id="footer"> -<p class="apache">Copyright 2007 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> +<p class="apache">Copyright 2008 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> <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> </body></html>
\ No newline at end of file diff --git a/docs/manual/rewrite/rewrite_tech.html b/docs/manual/rewrite/rewrite_tech.html index 4e06869f..18b37ed7 100644 --- a/docs/manual/rewrite/rewrite_tech.html +++ b/docs/manual/rewrite/rewrite_tech.html @@ -1,3 +1,5 @@ +# GENERATED FROM XML -- DO NOT EDIT + URI: rewrite_tech.html.en Content-Language: en Content-type: text/html; charset=ISO-8859-1 diff --git a/docs/manual/rewrite/rewrite_tech.html.en b/docs/manual/rewrite/rewrite_tech.html.en index b18aff71..75158d6a 100644 --- a/docs/manual/rewrite/rewrite_tech.html.en +++ b/docs/manual/rewrite/rewrite_tech.html.en @@ -14,9 +14,9 @@ <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> <p class="apache">Apache HTTP Server Version 2.2</p> <img alt="" src="../images/feather.gif" /></div> -<div class="up"><a href="./index.html"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> +<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> <div id="path"> -<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Technical Details</h1> +<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Technical Details</h1> <div class="toplang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_tech.html" title="English"> en </a></p> </div> @@ -29,9 +29,9 @@ and URL matching.</p> <li><img alt="" src="../images/down.gif" /> <a href="#InternalRuleset">Ruleset Processing</a></li> </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="rewrite_intro.html">mod_rewrite -introduction</a></li><li><a href="rewrite_guide.html">Practical solutions to common -problems</a></li><li><a href="rewrite_guide_advanced.html">Practical solutions to -advanced problems</a></li></ul></div> +introduction</a></li><li><a href="rewrite_guide.html">Rewrite Guide - useful +examples</a></li><li><a href="rewrite_guide_advanced.html">Advanced Rewrite Guide - +advanced useful examples</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="Internal" id="Internal">Internal Processing</a></h2> @@ -162,6 +162,6 @@ advanced problems</a></li></ul></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/rewrite_tech.html" title="English"> en </a></p> </div><div id="footer"> -<p class="apache">Copyright 2007 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> +<p class="apache">Copyright 2008 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> <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> </body></html>
\ No newline at end of file |