</section>
-<section id="static-to-dynamic">
-
- <title>From Static to Dynamic</title>
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>How can we transform a static page
- <code>foo.html</code> into a dynamic variant
- <code>foo.cgi</code> in a seamless way, i.e. without notice
- by the browser/user.</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>We just rewrite the URL to the CGI-script and force the
- 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>
-
-<highlight language="config">
-RewriteEngine on
-RewriteBase "/~quux/"
-RewriteRule "^foo\.html$" "foo.cgi" [H=<strong>cgi-script</strong>]
-</highlight>
- </dd>
- </dl>
-
-</section>
-
<section id="backward-compatibility">
<title>Backward Compatibility for file extension change</title>
</section>
-<section id="archive-access-multiplexer">
-
- <title>Redirecting to Geographically Distributed Servers</title>
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>We have numerous mirrors of our website, and want to redirect
- people to the one that is located in the country where they are
- located.</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>Looking at the hostname of the requesting client, we determine
- which country they are coming from. If we can't do a lookup on their
- IP address, we fall back to a default server.</p>
- <p>We'll use a <directive module="mod_rewrite">RewriteMap</directive>
- directive to build a list of servers that we wish to use.</p>
-
-<highlight language="config">
-HostnameLookups on
-RewriteEngine on
-RewriteMap multiplex "txt:/path/to/map.mirrors"
-RewriteCond "%{REMOTE_HOST}" "([a-z]+)$" [NC]
-RewriteRule "^/(.*)$" "${multiplex:<strong>%1</strong>|http://www.example.com/}$1" [R,L]
-</highlight>
-
-<example>
-## map.mirrors -- Multiplexing Map<br />
-<br />
-de http://www.example.de/<br />
-uk http://www.example.uk/<br />
-com http://www.example.com/<br />
-##EOF##
-</example>
- </dd>
-
- <dt>Discussion</dt>
- <dd>
- <note type="warning">This ruleset relies on
- <directive module="core">HostNameLookups</directive>
- being set <code>on</code>, which can be
- a significant performance hit.</note>
-
- <p>The <directive module="mod_rewrite">RewriteCond</directive>
- directive captures the last portion of the hostname of the
- requesting client - the country code - and the following RewriteRule
- uses that value to look up the appropriate mirror host in the map
- file.</p>
- </dd>
- </dl>
-
-</section>
-
<section id="canonicalurl">
<title>Canonical URLs</title>