tech.html.en revision 53abc235688d883cfa15cdfec354ba03128f357a
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<?xml version="1.0" encoding="ISO-8859-1"?>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering This file is generated from xml source: DO NOT EDIT
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<title>Apache mod_rewrite Technical Details - Apache HTTP Server</title>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<link href="/images/favicon.ico" rel="shortcut icon" /></head>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<body id="manual-page"><div id="page-header">
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<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>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<p class="apache">Apache HTTP Server Version 2.3</p>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<img alt="" src="/images/feather.gif" /></div>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<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.3</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Apache mod_rewrite Technical Details</h1>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<p><span>Available Languages: </span><a href="/en/rewrite/tech.html" title="English"> en </a> |
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<a href="/fr/rewrite/tech.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a></p>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<p>This document discusses some of the technical details of mod_rewrite
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poetteringand URL matching.</p>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#Internal">Internal Processing</a></li>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<li><img alt="" src="/images/down.gif" /> <a href="#InternalAPI">API Phases</a></li>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<li><img alt="" src="/images/down.gif" /> <a href="#InternalRuleset">Ruleset Processing</a></li>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering</ul><h3>See also</h3><ul class="seealso"><li><a href="/mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<h2><a name="Internal" id="Internal">Internal Processing</a></h2>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering <p>The internal processing of this module is very complex but
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering needs to be explained once even to the average user to avoid
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering common mistakes and to let you exploit its full
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering functionality.</p>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering<h2><a name="InternalAPI" id="InternalAPI">API Phases</a></h2>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering <p>First you have to understand that when Apache processes a
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering HTTP request it does this in phases. A hook for each of these
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering phases is provided by the Apache API. Mod_rewrite uses two of
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering these hooks: the URL-to-filename translation hook which is
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering used after the HTTP request has been read but before any
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering authorization starts and the Fixup hook which is triggered
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering after the authorization phases and after the per-directory
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering config files (<code>.htaccess</code>) have been read, but
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering before the content handler is activated.</p>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering <p>So, after a request comes in and Apache has determined the
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering corresponding server (or virtual server) the rewriting engine
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering starts processing of all mod_rewrite directives from the
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering per-server configuration in the URL-to-filename phase. A few
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering steps later when the final data directories are found, the
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering per-directory configuration directives of mod_rewrite are
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering triggered in the Fixup phase. In both situations mod_rewrite
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering rewrites URLs either to new URLs or to filenames, although
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering there is no obvious distinction between them. This is a usage
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering of the API which was not intended to be this way when the API
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering was designed, but as of Apache 1.x this is the only way
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering mod_rewrite can operate. To make this point more clear
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering remember the following two points:</p>
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering <li>Although mod_rewrite rewrites URLs to URLs, URLs to
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering filenames and even filenames to filenames, the API
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering currently provides only a URL-to-filename hook. In Apache
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering 2.0 the two missing hooks will be added to make the
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering processing more clear. But this point has no drawbacks for
f59e0b64351adec735d06ccf0d0ff0eb31c902c0Lennart Poettering the user, it is just a fact which should be remembered:
through the ruleset rule by rule (<code class="directive"><a href="/mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> directives) and
<img src="/images/rewrite_rule_flow.png" alt="Flow of RewriteRule and RewriteCond matching" /><br />
<p><span>Available Languages: </span><a href="/en/rewrite/tech.html" title="English"> en </a> |
<a href="/fr/rewrite/tech.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a></p>
<p class="apache">Copyright 2011 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>