You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2009/11/03 01:55:57 UTC
svn commit: r832236 - in /httpd/httpd/trunk/docs/manual/rewrite:
index.xml.tr remapping.html.en remapping.xml rewrite_guide.html.en
rewrite_guide.xml
Author: rbowen
Date: Tue Nov 3 00:55:56 2009
New Revision: 832236
URL: http://svn.apache.org/viewvc?rev=832236&view=rev
Log:
Moves another rule over to the category-specific file, and updates it
to use more efficient techniques.
Modified:
httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr
httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en
httpd/httpd/trunk/docs/manual/rewrite/remapping.xml
httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en
httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml
Modified: httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr?rev=832236&r1=832235&r2=832236&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr [utf-8] (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/index.xml.tr [utf-8] Tue Nov 3 00:55:56 2009
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 636374:832183 (outdated) -->
+<!-- English Revision: 636374:832217 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en?rev=832236&r1=832235&r2=832236&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en Tue Nov 3 00:55:56 2009
@@ -40,6 +40,7 @@
<li><img alt="" src="../images/down.gif" /> <a href="#backward-compatibility">Backward Compatibility for file extension change</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#canonicalhost">Canonical Hostnames</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#multipledirs">Search for pages in more than one directory</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#archive-access-multiplexer">Redirecting to Geographically Distributed Servers</a></li>
</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></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
@@ -291,6 +292,63 @@
</dd>
</dl>
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="archive-access-multiplexer" id="archive-access-multiplexer">Redirecting to Geographically Distributed Servers</a></h2>
+
+
+
+ <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 <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code>
+ directive to build a list of servers that we wish to use.</p>
+
+<div class="example"><pre>
+HostnameLookups on
+RewriteEngine on
+RewriteMap multiplex txt:/path/to/map.mirrors
+RewriteCond %{REMOTE_HOST} ([a-z]+)$ [NC]
+RewriteRule ^(.*)$ ${multiplex:<strong>%1</strong>|www.example.com}$1 [R,L]
+</pre></div>
+
+<div class="example"><pre>
+## map.mirrors -- Multiplexing Map
+
+de http://www.example.de/
+uk http://www.example.uk/
+com http://www.example.com/
+##EOF##
+</pre></div>
+ </dd>
+
+ <dt>Discussion</dt>
+ <dd>
+ <div class="warning">This ruleset relies on
+ <code class="directive"><a href="../mod/core.html#hostnamelookups">HostNameLookups</a></code>
+ being set <code>on</code>, which can be
+ a significant performance hit.</div>
+
+ <p>The <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>
+ 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>
+
</div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/rewrite/remapping.html" title="English"> en </a></p>
Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.xml?rev=832236&r1=832235&r2=832236&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/remapping.xml (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/remapping.xml Tue Nov 3 00:55:56 2009
@@ -294,4 +294,62 @@
</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 <directive module="mod_rewrite">RewriteMap</directive>
+ directive to build a list of servers that we wish to use.</p>
+
+<example><pre>
+HostnameLookups on
+RewriteEngine on
+RewriteMap multiplex txt:/path/to/map.mirrors
+RewriteCond %{REMOTE_HOST} ([a-z]+)$ [NC]
+RewriteRule ^(.*)$ ${multiplex:<strong>%1</strong>|www.example.com}$1 [R,L]
+</pre></example>
+
+<example><pre>
+## map.mirrors -- Multiplexing Map
+
+de http://www.example.de/
+uk http://www.example.uk/
+com http://www.example.com/
+##EOF##
+</pre></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>
+
+
</manualpage>
Modified: httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en?rev=832236&r1=832235&r2=832236&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en Tue Nov 3 00:55:56 2009
@@ -54,9 +54,6 @@
<li><img alt="" src="../images/down.gif" /> <a href="#external-rewriting">External Rewriting Engine</a></li>
<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 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>
@@ -610,260 +607,6 @@
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
-<h2><a name="filereorg" id="filereorg">Filesystem Reorganization</a></h2>
-
-
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>This really is a hardcore example: a killer application
- which heavily uses per-directory
- <code>RewriteRules</code> to get a smooth look and feel
- on the Web while its data structure is never touched or
- 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 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
- directories where I stored the packages:</p>
-
-<div class="example"><pre>
-drwxrwxr-x 2 netsw users 512 Aug 3 18:39 Audio/
-drwxrwxr-x 2 netsw users 512 Jul 9 14:37 Benchmark/
-drwxrwxr-x 12 netsw users 512 Jul 9 00:34 Crypto/
-drwxrwxr-x 5 netsw users 512 Jul 9 00:41 Database/
-drwxrwxr-x 4 netsw users 512 Jul 30 19:25 Dicts/
-drwxrwxr-x 10 netsw users 512 Jul 9 01:54 Graphic/
-drwxrwxr-x 5 netsw users 512 Jul 9 01:58 Hackers/
-drwxrwxr-x 8 netsw users 512 Jul 9 03:19 InfoSys/
-drwxrwxr-x 3 netsw users 512 Jul 9 03:21 Math/
-drwxrwxr-x 3 netsw users 512 Jul 9 03:24 Misc/
-drwxrwxr-x 9 netsw users 512 Aug 1 16:33 Network/
-drwxrwxr-x 2 netsw users 512 Jul 9 05:53 Office/
-drwxrwxr-x 7 netsw users 512 Jul 9 09:24 SoftEng/
-drwxrwxr-x 7 netsw users 512 Jul 9 12:17 System/
-drwxrwxr-x 12 netsw users 512 Aug 3 20:15 Typesetting/
-drwxrwxr-x 10 netsw users 512 Jul 9 14:08 X11/
-</pre></div>
-
- <p>In July 1996 I decided to make this archive public to
- 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 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 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>
-
- <dd>
- <p>The solution has two parts: The first is a set of CGI
- scripts which create all the pages at all directory
- levels on-the-fly. I put them under
- <code>/e/netsw/.www/</code> as follows:</p>
-
-<div class="example"><pre>
--rw-r--r-- 1 netsw users 1318 Aug 1 18:10 .wwwacl
-drwxr-xr-x 18 netsw users 512 Aug 5 15:51 DATA/
--rw-rw-rw- 1 netsw users 372982 Aug 5 16:35 LOGFILE
--rw-r--r-- 1 netsw users 659 Aug 4 09:27 TODO
--rw-r--r-- 1 netsw users 5697 Aug 1 18:01 netsw-about.html
--rwxr-xr-x 1 netsw users 579 Aug 2 10:33 netsw-access.pl
--rwxr-xr-x 1 netsw users 1532 Aug 1 17:35 netsw-changes.cgi
--rwxr-xr-x 1 netsw users 2866 Aug 5 14:49 netsw-home.cgi
-drwxr-xr-x 2 netsw users 512 Jul 8 23:47 netsw-img/
--rwxr-xr-x 1 netsw users 24050 Aug 5 15:49 netsw-lsdir.cgi
--rwxr-xr-x 1 netsw users 1589 Aug 3 18:43 netsw-search.cgi
--rwxr-xr-x 1 netsw users 1885 Aug 1 17:41 netsw-tree.cgi
--rw-r--r-- 1 netsw users 234 Jul 30 16:35 netsw-unlimit.lst
-</pre></div>
-
- <p>The <code>DATA/</code> subdirectory holds the above
- 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
- tree? We want to hide the <code>DATA/</code> directory
- from the user while running the appropriate CGI scripts
- 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 public URL path
- <code>/net.sw/</code> to the internal path
- <code>/e/netsw</code>:</p>
-
-<div class="example"><pre>
-RewriteRule ^net.sw$ net.sw/ [R]
-RewriteRule ^net.sw/(.*)$ e/netsw/$1
-</pre></div>
-
- <p>The first rule is for requests which miss the trailing
- slash! The second rule does the real thing. And then
- comes the killer configuration which stays in the
- per-directory config file
- <code>/e/netsw/.www/.wwwacl</code>:</p>
-
-<div class="example"><pre>
-Options ExecCGI FollowSymLinks Includes MultiViews
-
-RewriteEngine on
-
-# we are reached via /net.sw/ prefix
-RewriteBase /net.sw/
-
-# first we rewrite the root dir to
-# the handling cgi script
-RewriteRule ^$ netsw-home.cgi [L]
-RewriteRule ^index\.html$ netsw-home.cgi [L]
-
-# strip out the subdirs when
-# the browser requests us from perdir pages
-RewriteRule ^.+/(netsw-[^/]+/.+)$ $1 [L]
-
-# and now break the rewriting for local files
-RewriteRule ^netsw-home\.cgi.* - [L]
-RewriteRule ^netsw-changes\.cgi.* - [L]
-RewriteRule ^netsw-search\.cgi.* - [L]
-RewriteRule ^netsw-tree\.cgi$ - [L]
-RewriteRule ^netsw-about\.html$ - [L]
-RewriteRule ^netsw-img/.*$ - [L]
-
-# anything else is a subdir which gets handled
-# by another cgi script
-RewriteRule !^netsw-lsdir\.cgi.* - [C]
-RewriteRule (.*) netsw-lsdir.cgi/$1
-</pre></div>
-
- <p>Some hints for interpretation:</p>
-
- <ol>
- <li>Notice the <code>L</code> (last) flag and no
- 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
- in the last part</li>
-
- <li>Notice the catch-all pattern in the last rule</li>
- </ol>
- </dd>
- </dl>
-
- </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 Another Web Server</a></h2>
-
-
-
- <dl>
- <dt>Description:</dt>
-
- <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
- there is also a <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> solution.
- 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>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>The first solution has the best performance but less
- flexibility, and is less safe:</p>
-
-<div class="example"><pre>
-RewriteEngine on
-RewriteCond %{DOCUMENT_ROOT/%{REQUEST_URI} <strong>!-f</strong>
-RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1
-</pre></div>
-
- <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 a better variant:</p>
-
-<div class="example"><pre>
-RewriteEngine on
-RewriteCond %{REQUEST_URI} <strong>!-U</strong>
-RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1
-</pre></div>
-
- <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 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 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><a name="archive-access-multiplexer" id="archive-access-multiplexer">Archive Access Multiplexer</a></h2>
-
-
-
- <dl>
- <dt>Description:</dt>
-
- <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>?
- 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 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
- <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code>
- over the top-level domain of the client.
- With a tricky chained ruleset we can use this top-level
- domain as a key to our multiplexing map.</p>
-
-<div class="example"><pre>
-RewriteEngine on
-RewriteMap multiplex txt:/path/to/map.cxan
-RewriteRule ^/CxAN/(.*) %{REMOTE_HOST}::$1 [C]
-RewriteRule ^.+\.<strong>([a-zA-Z]+)</strong>::(.*)$ ${multiplex:<strong>$1</strong>|ftp.default.dom}$2 [R,L]
-</pre></div>
-
-<div class="example"><pre>
-##
-## map.cxan -- Multiplexing Map for CxAN
-##
-
-de ftp://ftp.cxan.de/CxAN/
-uk ftp://ftp.cxan.uk/CxAN/
-com ftp://ftp.cxan.com/CxAN/
- :
-##EOF##
-</pre></div>
- </dd>
- </dl>
-
- </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
-<div class="section">
<h2><a name="browser-dependent-content" id="browser-dependent-content">Browser Dependent Content</a></h2>
Modified: httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml?rev=832236&r1=832235&r2=832236&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml Tue Nov 3 00:55:56 2009
@@ -593,263 +593,6 @@
</section>
- <section id="filereorg">
-
- <title>Filesystem Reorganization</title>
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>This really is a hardcore example: a killer application
- which heavily uses per-directory
- <code>RewriteRules</code> to get a smooth look and feel
- on the Web while its data structure is never touched or
- 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 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
- directories where I stored the packages:</p>
-
-<example><pre>
-drwxrwxr-x 2 netsw users 512 Aug 3 18:39 Audio/
-drwxrwxr-x 2 netsw users 512 Jul 9 14:37 Benchmark/
-drwxrwxr-x 12 netsw users 512 Jul 9 00:34 Crypto/
-drwxrwxr-x 5 netsw users 512 Jul 9 00:41 Database/
-drwxrwxr-x 4 netsw users 512 Jul 30 19:25 Dicts/
-drwxrwxr-x 10 netsw users 512 Jul 9 01:54 Graphic/
-drwxrwxr-x 5 netsw users 512 Jul 9 01:58 Hackers/
-drwxrwxr-x 8 netsw users 512 Jul 9 03:19 InfoSys/
-drwxrwxr-x 3 netsw users 512 Jul 9 03:21 Math/
-drwxrwxr-x 3 netsw users 512 Jul 9 03:24 Misc/
-drwxrwxr-x 9 netsw users 512 Aug 1 16:33 Network/
-drwxrwxr-x 2 netsw users 512 Jul 9 05:53 Office/
-drwxrwxr-x 7 netsw users 512 Jul 9 09:24 SoftEng/
-drwxrwxr-x 7 netsw users 512 Jul 9 12:17 System/
-drwxrwxr-x 12 netsw users 512 Aug 3 20:15 Typesetting/
-drwxrwxr-x 10 netsw users 512 Jul 9 14:08 X11/
-</pre></example>
-
- <p>In July 1996 I decided to make this archive public to
- 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 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 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>
-
- <dd>
- <p>The solution has two parts: The first is a set of CGI
- scripts which create all the pages at all directory
- levels on-the-fly. I put them under
- <code>/e/netsw/.www/</code> as follows:</p>
-
-<example><pre>
--rw-r--r-- 1 netsw users 1318 Aug 1 18:10 .wwwacl
-drwxr-xr-x 18 netsw users 512 Aug 5 15:51 DATA/
--rw-rw-rw- 1 netsw users 372982 Aug 5 16:35 LOGFILE
--rw-r--r-- 1 netsw users 659 Aug 4 09:27 TODO
--rw-r--r-- 1 netsw users 5697 Aug 1 18:01 netsw-about.html
--rwxr-xr-x 1 netsw users 579 Aug 2 10:33 netsw-access.pl
--rwxr-xr-x 1 netsw users 1532 Aug 1 17:35 netsw-changes.cgi
--rwxr-xr-x 1 netsw users 2866 Aug 5 14:49 netsw-home.cgi
-drwxr-xr-x 2 netsw users 512 Jul 8 23:47 netsw-img/
--rwxr-xr-x 1 netsw users 24050 Aug 5 15:49 netsw-lsdir.cgi
--rwxr-xr-x 1 netsw users 1589 Aug 3 18:43 netsw-search.cgi
--rwxr-xr-x 1 netsw users 1885 Aug 1 17:41 netsw-tree.cgi
--rw-r--r-- 1 netsw users 234 Jul 30 16:35 netsw-unlimit.lst
-</pre></example>
-
- <p>The <code>DATA/</code> subdirectory holds the above
- 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
- tree? We want to hide the <code>DATA/</code> directory
- from the user while running the appropriate CGI scripts
- for the various URLs. Here is the solution: first I put
- the following into the per-directory configuration file
- in the <directive module="core">DocumentRoot</directive>
- of the server to rewrite the public URL path
- <code>/net.sw/</code> to the internal path
- <code>/e/netsw</code>:</p>
-
-<example><pre>
-RewriteRule ^net.sw$ net.sw/ [R]
-RewriteRule ^net.sw/(.*)$ e/netsw/$1
-</pre></example>
-
- <p>The first rule is for requests which miss the trailing
- slash! The second rule does the real thing. And then
- comes the killer configuration which stays in the
- per-directory config file
- <code>/e/netsw/.www/.wwwacl</code>:</p>
-
-<example><pre>
-Options ExecCGI FollowSymLinks Includes MultiViews
-
-RewriteEngine on
-
-# we are reached via /net.sw/ prefix
-RewriteBase /net.sw/
-
-# first we rewrite the root dir to
-# the handling cgi script
-RewriteRule ^$ netsw-home.cgi [L]
-RewriteRule ^index\.html$ netsw-home.cgi [L]
-
-# strip out the subdirs when
-# the browser requests us from perdir pages
-RewriteRule ^.+/(netsw-[^/]+/.+)$ $1 [L]
-
-# and now break the rewriting for local files
-RewriteRule ^netsw-home\.cgi.* - [L]
-RewriteRule ^netsw-changes\.cgi.* - [L]
-RewriteRule ^netsw-search\.cgi.* - [L]
-RewriteRule ^netsw-tree\.cgi$ - [L]
-RewriteRule ^netsw-about\.html$ - [L]
-RewriteRule ^netsw-img/.*$ - [L]
-
-# anything else is a subdir which gets handled
-# by another cgi script
-RewriteRule !^netsw-lsdir\.cgi.* - [C]
-RewriteRule (.*) netsw-lsdir.cgi/$1
-</pre></example>
-
- <p>Some hints for interpretation:</p>
-
- <ol>
- <li>Notice the <code>L</code> (last) flag and no
- 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
- in the last part</li>
-
- <li>Notice the catch-all pattern in the last rule</li>
- </ol>
- </dd>
- </dl>
-
- </section>
-
- <section id="redirect404">
-
- <title>Redirect Failing URLs to Another Web Server</title>
-
- <dl>
- <dt>Description:</dt>
-
- <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 <directive module="core"
- >ErrorDocument</directive> CGI scripts in Perl, but
- there is also a <module>mod_rewrite</module> solution.
- But note that this performs more poorly than using an
- <directive module="core">ErrorDocument</directive>
- CGI script!</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>The first solution has the best performance but less
- flexibility, and is less safe:</p>
-
-<example><pre>
-RewriteEngine on
-RewriteCond %{DOCUMENT_ROOT/%{REQUEST_URI} <strong>!-f</strong>
-RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1
-</pre></example>
-
- <p>The problem here is that this will only work for pages
- inside the <directive module="core">DocumentRoot</directive>. While you can add more
- Conditions (for instance to also handle homedirs, etc.)
- there is a better variant:</p>
-
-<example><pre>
-RewriteEngine on
-RewriteCond %{REQUEST_URI} <strong>!-U</strong>
-RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1
-</pre></example>
-
- <p>This uses the URL look-ahead feature of <module>mod_rewrite</module>.
- The result is that this will work for all types of URLs
- 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 an <directive module="core"
- >ErrorDocument</directive> CGI script.</p>
- </dd>
- </dl>
-
- </section>
-
- <section id="archive-access-multiplexer">
-
- <title>Archive Access Multiplexer</title>
-
- <dl>
- <dt>Description:</dt>
-
- <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>?
- 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 <module>mod_rewrite</module>?</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>First we notice that as of version 3.0.0,
- <module>mod_rewrite</module> can
- also use the "<code>ftp:</code>" scheme on redirects.
- And second, the location approximation can be done by a
- <directive module="mod_rewrite">RewriteMap</directive>
- over the top-level domain of the client.
- With a tricky chained ruleset we can use this top-level
- domain as a key to our multiplexing map.</p>
-
-<example><pre>
-RewriteEngine on
-RewriteMap multiplex txt:/path/to/map.cxan
-RewriteRule ^/CxAN/(.*) %{REMOTE_HOST}::$1 [C]
-RewriteRule ^.+\.<strong>([a-zA-Z]+)</strong>::(.*)$ ${multiplex:<strong>$1</strong>|ftp.default.dom}$2 [R,L]
-</pre></example>
-
-<example><pre>
-##
-## map.cxan -- Multiplexing Map for CxAN
-##
-
-de ftp://ftp.cxan.de/CxAN/
-uk ftp://ftp.cxan.uk/CxAN/
-com ftp://ftp.cxan.com/CxAN/
- :
-##EOF##
-</pre></example>
- </dd>
- </dl>
-
- </section>
-
<section id="browser-dependent-content">
<title>Browser Dependent Content</title>