]> granicus.if.org Git - apache/commitdiff
xforms
authorDaniel Gruno <humbedooh@apache.org>
Wed, 25 Apr 2012 14:37:54 +0000 (14:37 +0000)
committerDaniel Gruno <humbedooh@apache.org>
Wed, 25 Apr 2012 14:37:54 +0000 (14:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1330313 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/rewrite/access.html.en
docs/manual/rewrite/advanced.html.en
docs/manual/rewrite/avoid.html.en
docs/manual/rewrite/flags.html.en
docs/manual/rewrite/intro.xml.fr
docs/manual/rewrite/intro.xml.meta
docs/manual/rewrite/proxy.html.en
docs/manual/rewrite/remapping.html.en
docs/manual/rewrite/rewritemap.html.en
docs/manual/rewrite/vhosts.html.en

index 6df1602775a6bc0bc3b6bdfeee59141097a36fb2..b31b8fcaff781a4ffa8e980b9acadef5b2f08cf5 100644 (file)
@@ -78,29 +78,32 @@ configuration.</div>
 
 
 
-<div class="example"><p><code>
-RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br />
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_REFERER} <strong>!^$</strong>
+RewriteCond %{HTTP_REFERER} !www.example.com [NC]
 RewriteRule <strong>\.(gif|jpg|png)$</strong>    -   [F,NC]
-</code></p></div>
+</pre>
+
 
     <p>In this second example, instead of failing the request, we display
     an alternate image instead.</p>
 
-<div class="example"><p><code>
-RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br />
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_REFERER} <strong>!^$</strong>
+RewriteCond %{HTTP_REFERER} !www.example.com [NC]
 RewriteRule <strong>\.(gif|jpg|png)$</strong>    /images/go-away.png   [R,NC]
-</code></p></div>
+</pre>
+
 
     <p>In the third example, we redirect the request to an image on some
     other site.</p>
 
-<div class="example"><p><code>
-RewriteCond %{HTTP_REFERER} <strong>!^$</strong><br />
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_REFERER} <strong>!^$</strong>
+RewriteCond %{HTTP_REFERER} !www.example.com [NC]
 RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif   [R,NC]
-</code></p></div>
+</pre>
+
 
     <p>Of these techniques, the last two tend to be the most effective
     in getting people to stop hotlinking your images, because they will
@@ -115,14 +118,15 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif
         than redirecting that request elsewhere, this can be
         accomplished without the use of mod_rewrite:</p>
 
-        <div class="example"><p><code>
-        SetEnvIf Referer example\.com localreferer<br />
-        &lt;FilesMatch \.(jpg|png|gif)$&gt;<br />
-        Order deny,allow<br />
-        Deny from all<br />
-        Allow from env=localreferer<br />
-        &lt;/FilesMatch&gt;
-        </code></p></div>
+        <pre class="prettyprint lang-config">
+SetEnvIf Referer example\.com localreferer
+&lt;FilesMatch \.(jpg|png|gif)$&gt;
+       Order deny,allow
+       Deny from all
+       Allow from env=localreferer
+&lt;/FilesMatch&gt;
+        </pre>
+
         </dd>
       </dl>
 
@@ -165,11 +169,12 @@ RewriteRule <strong>\.(gif|jpg|png)$</strong> http://other.example.com/image.gif
         range, if you are trying to block that user agent only from the
         particular source.</p>
 
-<div class="example"><p><code>
-RewriteCond %{HTTP_USER_AGENT}   ^<strong>NameOfBadRobot</strong><br />
-RewriteCond %{REMOTE_ADDR}       =<strong>123\.45\.67\.[8-9]</strong><br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_USER_AGENT}   ^<strong>NameOfBadRobot</strong>
+RewriteCond %{REMOTE_ADDR}       =<strong>123\.45\.67\.[8-9]</strong>
 RewriteRule ^<strong>/secret/files/</strong>   -   [<strong>F</strong>]
-</code></p></div>
+</pre>
+
         </dd>
 
       <dt>Discussion:</dt>
@@ -179,14 +184,15 @@ RewriteRule ^<strong>/secret/files/</strong>   -   [<strong>F</strong>]
         Rather than using mod_rewrite for this, you can accomplish the
         same end using alternate means, as illustrated here:
       </p>
-      <div class="example"><p><code>
-      SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway<br />
-      &lt;Location /secret/files&gt;<br />
-      Order allow,deny<br />
-      Allow from all<br />
-      Deny from env=goaway<br />
-      &lt;/Location&gt;
-      </code></p></div>
+      <pre class="prettyprint lang-config">
+SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway
+&lt;Location /secret/files&gt;
+       Order allow,deny
+       Allow from all
+       Deny from env=goaway
+&lt;/Location&gt;
+      </pre>
+
       <p>
       As noted above, this technique is trivial to circumvent, by simply
       modifying the <code>USER_AGENT</code> request header. If you
@@ -216,13 +222,14 @@ RewriteRule ^<strong>/secret/files/</strong>   -   [<strong>F</strong>]
     <dt>Solution:</dt>
 
     <dd>
-<div class="example"><p><code>
-RewriteEngine on<br />
-RewriteMap    hosts-deny  txt:/path/to/hosts.deny<br />
-RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]<br />
-RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
+RewriteMap    hosts-deny  txt:/path/to/hosts.deny
+RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
+RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND
 RewriteRule   ^  -  [F]
-</code></p></div>
+</pre>
+
 
 <div class="example"><p><code>
 ##<br />
@@ -270,17 +277,18 @@ bsdti1.sdm.de  -<br />
   <p>The following ruleset uses a map file to associate each Referer
   with a redirection target.</p>
 
-<div class="example"><p><code>
-RewriteMap  deflector txt:/path/to/deflector.map<br />
-<br />
-RewriteCond %{HTTP_REFERER} !=""<br />
-RewriteCond ${deflector:%{HTTP_REFERER}} =-<br />
-RewriteRule ^ %{HTTP_REFERER} [R,L]<br />
-<br />
-RewriteCond %{HTTP_REFERER} !=""<br />
-RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND<br />
+<pre class="prettyprint lang-config">
+RewriteMap  deflector txt:/path/to/deflector.map
+
+RewriteCond %{HTTP_REFERER} !=""
+RewriteCond ${deflector:%{HTTP_REFERER}} =-
+RewriteRule ^ %{HTTP_REFERER} [R,L]
+
+RewriteCond %{HTTP_REFERER} !=""
+RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
 RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]
-</code></p></div>
+</pre>
+
 
       <p>The map file lists redirection targets for each referer, or, if
       we just wish to redirect back to where they came from, a "-" is
index a0edc75dc39698da1b2bda1561adc2f047ed5e77..8d2415852e09d43443455a1113a37e6c867cc1f1 100644 (file)
@@ -91,13 +91,14 @@ http://physical_host_of_user1/u/user/anypath
       files assuming that server0 is a default server which will be used if
       a user has no entry in the map:</p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
-<br />
-RewriteMap      users-to-hosts   txt:/path/to/map.users-to-hosts<br />
-<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
+
+RewriteMap      users-to-hosts   txt:/path/to/map.users-to-hosts
+
 RewriteRule   ^/u/<strong>([^/]+)</strong>/?(.*)   http://<strong>${users-to-hosts:$1|server0}</strong>/u/$1/$2
-</code></p></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -126,11 +127,12 @@ RewriteRule   ^/u/<strong>([^/]+)</strong>/?(.*)   http://<strong>${users-to-hos
     <dd>
       This is done via the following ruleset:
 
-<div class="example"><p><code>
-# This example is valid in per-directory context only<br />
-RewriteCond %{REQUEST_URI}   <strong>!-U</strong><br />
+<pre class="prettyprint lang-config">
+# This example is valid in per-directory context only
+RewriteCond %{REQUEST_URI}   <strong>!-U</strong>
 RewriteRule ^(.+)\.html$          /regenerate_page.cgi   [PT,L]
-</code></p></div>
+</pre>
+
 
     <p>The <code>-U</code> operator determines whether the test string
     (in this case, <code>REQUEST_URI</code>) is a valid URL. It does
@@ -167,12 +169,13 @@ RewriteRule ^(.+)\.html$          /regenerate_page.cgi   [PT,L]
       <p>We'll use <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> and a list of servers
       to accomplish this.</p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
-RewriteMap lb rnd:/path/to/serverlist.txt<br />
-<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
+RewriteMap lb rnd:/path/to/serverlist.txt
+
 RewriteRule ^/(.*) http://${lb:servers}/$1 [P,L]
-</code></p></div>
+</pre>
+
 
 <p><code>serverlist.txt</code> will contain a list of the servers:</p>
 
@@ -223,9 +226,10 @@ featureful than anything you can cobble together using mod_rewrite.</p>
       URL causes the 'page' to be refreshed every time it is
       updated on the filesystem.</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 RewriteRule   ^(/[uge]/[^/]+/?.*):refresh  /internal/cgi/apache/nph-refresh?f=$1
-</code></p></div>
+</pre>
+
 
       <p>Now when we reference the URL</p>
 
@@ -243,7 +247,7 @@ RewriteRule   ^(/[uge]/[^/]+/?.*):refresh  /internal/cgi/apache/nph-refresh?f=$1
       one would usually say "left as an exercise to the reader"
       ;-) I will provide this, too.</p>
 
-<div class="example"><pre>
+<pre class="prettyprint lang-perl">
 #!/sw/bin/perl
 ##
 ##  nph-refresh -- NPH/CGI script for auto refreshing pages
@@ -345,7 +349,8 @@ while (1) {
 exit(0);
 
 ##EOF##
-</pre></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -374,10 +379,11 @@ exit(0);
       <p>We use the following ruleset to expand the tilde URLs
       into the above layout.</p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
 RewriteRule   ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*)  /home/<strong>$2</strong>/$1/public_html$3
-</code></p></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -433,13 +439,14 @@ RewriteRule   ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*)  /home/<strong>$2</stro
       <code>&gt;STRING</code> and <code>=STRING</code> we can
       do time-dependent redirects:</p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
-RewriteCond   %{TIME_HOUR}%{TIME_MIN} &gt;0700<br />
-RewriteCond   %{TIME_HOUR}%{TIME_MIN} &lt;1900<br />
-RewriteRule   ^foo\.html$             foo.day.html [L]<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
+RewriteCond   %{TIME_HOUR}%{TIME_MIN} &gt;0700
+RewriteCond   %{TIME_HOUR}%{TIME_MIN} &lt;1900
+RewriteRule   ^foo\.html$             foo.day.html [L]
 RewriteRule   ^foo\.html$             foo.night.html
-</code></p></div>
+</pre>
+
 
       <p>This provides the content of <code>foo.day.html</code>
       under the URL <code>foo.html</code> from
@@ -478,17 +485,19 @@ RewriteRule   ^foo\.html$             foo.night.html
     <dd>
       <p>Use the [E] flag to set an environment variable.</p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
 RewriteRule   ^/horse/(.*)   /pony/$1 [E=<strong>rewritten:1</strong>]
-</code></p></div>
+</pre>
+
 
     <p>Later in your ruleset you might check for this environment
     variable using a RewriteCond:</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 RewriteCond %{ENV:rewritten} =1
-</code></p></div>
+</pre>
+
 
     <p>Note that environment variables do not survive an external
     redirect. You might consider using the [CO] flag to set a
index 083ec3445315562cca5444cf4f719e2f3c760211..5185a43752e6416009549c5ebdf986c63dfd653f 100644 (file)
@@ -83,25 +83,24 @@ and <code>/one/three/four.html</code>.</p>
 <p>To redirect URLs under <code>/one</code> to
 <code>http://one.example.com</code>, do the following:</p>
 
-<div class="example"><p><code>
-Redirect /one/ http://one.example.com/
-</code></p></div>
+<pre class="prettyprint lang-config">Redirect /one/ http://one.example.com/</pre>
+
 
 <p>To redirect <code>http</code> URLs to <code>https</code>, do the
 following:</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 &lt;VirtualHost *:80&gt;
-ServerName www.example.com<br />
-Redirect / https://www.example.com/<br />
+       ServerName www.example.com
+       Redirect / https://www.example.com/
 &lt;/VirtualHost &gt;
-<br />
+
 &lt;VirtualHost *:443&gt;
-ServerName www.example.com<br />
-<br />
-# ... SSL configuration goes here<br />
+       ServerName www.example.com
+       # ... SSL configuration goes here
 &lt;/VirtualHost &gt;
-</code></p></div>
+</pre>
+
 
 <p>The use of <code>RewriteRule</code> to perform this task may be
 appropriate if there are other <code>RewriteRule</code> directives in
@@ -126,7 +125,8 @@ is possible to perform this mapping with <code>mod_rewrite</code>,
 and performance.</p>
 
 <div class="example"><h3>Using Alias</h3><p><code>
-Alias /cats /var/www/virtualhosts/felines/htdocs
+<pre class="prettyprint lang-config">Alias /cats /var/www/virtualhosts/felines/htdocs</pre>
+
 </code></p></div>
 
 <p>
@@ -167,25 +167,28 @@ seems like the right approach.</p>
 <p><code>RewriteRule</code> provides the <a href="flags.html#flag_p">[P]</a> flag to pass rewritten URIs through
 <code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>.</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P]
-</code></p></div>
+</pre>
+
 
 <p>However, in many cases, when there is no actual pattern matching
 needed, as in the example shown above, the <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code> directive is a better choice.
 The example here could be rendered as:</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 ProxyPass /images/ http://imageserver.local/images/
-</code></p></div>
+</pre>
+
 
 <p>Note that whether you use <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> or <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code>, you'll still need to use the
 <code class="directive"><a href="../mod/mod_proxy.html#proxypassreverse">ProxyPassReverse</a></code> directive to
 catch redirects issued from the back-end server:</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 ProxyPassReverse /images/ http://imageserver.local/images/
-</code></p></div>
+</pre>
+
 
 <p>You may need to use <code>RewriteRule</code> instead when there are
 other <code>RewriteRule</code>s in effect in the same scope, as a
@@ -207,11 +210,12 @@ variable or request header. This can be done more efficiently using the
 hostname, such as <code>www.example.com</code> instead of
 <code>example.com</code>. This can be done using the <code class="directive"><a href="../mod/core.html#if">&lt;If&gt;</a></code> directive, as shown here:</p>
 
-<div class="example"><p><code>
-&lt;If "$req{Host} != 'www.example.com'"&gt;<br />
-RedirectMatch (.*) http://www.example.com$1<br />
+<pre class="prettyprint lang-config">
+&lt;If "$req{Host} != 'www.example.com'"&gt;
+       RedirectMatch (.*) http://www.example.com$1
 &lt;/If&gt;
-</code></p></div>
+</pre>
+
 
 <p>This technique can be used to take actions based on any request
 header, response header, or environment variable, replacing
index 2b195154c54097bd6db94e9d4b8c4795e940a1a3..416a6de6a807fa9e8d82985b0b42206139cb3018 100644 (file)
@@ -59,9 +59,8 @@ providing detailed explanations and examples.</p>
 its 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>
+<pre class="prettyprint lang-config">RewriteRule pattern target [Flag1,Flag2,Flag3]</pre>
+
 
 <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
@@ -91,9 +90,8 @@ so backreferences will be unescaped at the time they are applied.
 Using the B flag, non-alphanumeric characters in backreferences
 will be escaped. For example, consider the rule:</p>
 
-<div class="example"><p><code>
-RewriteRule ^search/(.*)$ /search.php?term=$1
-</code></p></div>
+<pre class="prettyprint lang-config">RewriteRule ^search/(.*)$ /search.php?term=$1</pre>
+
 
 <p>Given a search term of 'x &amp; y/z', a browser will encode it as
 'x%20%26%20y%2Fz', making the request 'search/x%20%26%20y%2Fz'. Without the B
@@ -177,10 +175,11 @@ browsers that support this feature.</dd>
 
 <p>Several examples are offered here:</p>
 
-<div class="example"><p><code>
-RewriteEngine On<br />
+<pre class="prettyprint lang-config">
+RewriteEngine On
 RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.com:1440:/]
-</code></p></div>
+</pre>
+
 
 <p>In the example give, the rule doesn't rewrite the request.
 The "-" rewrite target tells mod_rewrite to pass the request
@@ -265,10 +264,11 @@ 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 />
+<pre class="prettyprint lang-config">
+RewriteRule \.(png|gif|jpg) - [E=image:1]
 CustomLog logs/access_log combined env=!image
-</code></p></div>
+</pre>
+
 
 <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>
@@ -292,9 +292,8 @@ 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>
+<pre class="prettyprint lang-config">RewriteRule \.exe - [F]</pre>
+
 
 <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
@@ -313,9 +312,8 @@ 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>
+<pre class="prettyprint lang-config">RewriteRule oldproduct - [G,NC]</pre>
+
 
 <p>When using [G], an [L] is implied - that is, the response is returned
 immediately, and no further rules are evaluated.</p>
@@ -327,9 +325,8 @@ immediately, and no further rules are evaluated.</p>
 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>
+<pre class="prettyprint lang-config">RewriteRule !\. - [H=application/x-httpd-php]</pre>
+
 
 <p>
 The regular expression above - <code>!\.</code> - will match any request
@@ -341,9 +338,10 @@ For example, the following snippet used in per-server context allows
 <code>.php</code> files to be <em>displayed</em> by <code>mod_php</code>
 if they are requested with the <code>.phps</code> extension:</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source]
-</code></p></div>
+</pre>
+
 
 <p>The regular expression above - <code>^(/source/.+\.php)s$</code> - will
 match any request that starts with <code>/source/</code> followed by 1 or
@@ -390,11 +388,12 @@ redirects.</p>
 argument to <code>index.php</code>, however, the <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> ensures that if the request
 is already for <code>index.php</code>, the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> will be skipped.</p>
 
-<div class="example"><p><code>
-RewriteBase /<br />
-RewriteCond %{REQUEST_URI} !=/index.php<br />
+<pre class="prettyprint lang-config">
+RewriteBase /
+RewriteCond %{REQUEST_URI} !=/index.php
 RewriteRule ^(.*) /index.php?req=$1 [L,PT]
-</code></p></div>
+</pre>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_n" id="flag_n">N|next</a></h2>
@@ -410,9 +409,8 @@ 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>
+<pre class="prettyprint lang-config">RewriteRule (.*)A(.*) $1B$2 [N]</pre>
+
 
 <p>You can think of this as a <code>while</code> loop: While this
 pattern still matches (i.e., while the URI still contains an
@@ -431,9 +429,8 @@ 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>
+<pre class="prettyprint lang-config">RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]</pre>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flag_ne" id="flag_ne">NE|noescape</a></h2>
@@ -442,9 +439,8 @@ RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]
 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>
+<pre class="prettyprint lang-config">RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]</pre>
+
 
 <p>
 The above example will redirect <code>/anchor/xyz</code> to
@@ -485,9 +481,8 @@ requests.
 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>
+<pre class="prettyprint lang-config">RewriteRule /(.*)\.(jpg|gif|png) http://images.example.com/$1.$2 [P]</pre>
+
 
 <p>Use of the [P] flag implies [L] - that is, the request is immediately
 pushed through the proxy, and any following rules will not be
@@ -534,10 +529,11 @@ 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 />
+<pre class="prettyprint lang-config">
+Alias /icons /usr/local/apache/icons
 RewriteRule /pics/(.+)\.jpg /icons/$1.gif [PT]
-</code></p></div>
+</pre>
+
 
 <p>
 Omission of the [PT] flag in this case will cause the Alias to be
@@ -566,9 +562,8 @@ Using the [QSA] flag causes the query strings to be combined.
 
 <p>Consider the following rule:</p>
 
-<div class="example"><p><code>
-RewriteRule /pages/(.+) /page.php?page=$1 [QSA]
-</code></p></div>
+<pre class="prettyprint lang-config">RewriteRule /pages/(.+) /page.php?page=$1 [QSA]</pre>
+
 
 <p>With the [QSA] flag, a request for <code>/pages/123?one=two</code> will be
 mapped to <code>/page.php?page=123&amp;one=two</code>. Without the [QSA]
@@ -643,16 +638,17 @@ 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?<br />
-RewriteCond %{REQUEST_FILENAME} !-f<br />
-RewriteCond %{REQUEST_FILENAME} !-d<br />
-# If so, skip these two RewriteRules<br />
-RewriteRule .? - [S=2]<br />
-<br />
-RewriteRule (.*\.gif) images.php?$1<br />
+<pre class="prettyprint lang-config">
+# Is the request for a non-existent file?
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+# If so, skip these two RewriteRules
+RewriteRule .? - [S=2]
+
+RewriteRule (.*\.gif) images.php?$1
 RewriteRule (.*\.html) docs.php?$1
-</code></p></div>
+</pre>
+
 
 <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
@@ -662,26 +658,23 @@ negate those conditions and add a <code>RewriteRule</code> with a [Skip] flag. Y
 use this to make pseudo if-then-else constructs: The last rule of
 the then-clause becomes <code>skip=N</code>, where N is the
 number of rules in the else-clause:</p>
-<div class="example"><p><code>
-# Does the file exist?<br />
-RewriteCond %{REQUEST_FILENAME} !-f<br />
-RewriteCond %{REQUEST_FILENAME} !-d<br />
-# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.<br />
-RewriteRule .? - [S=3]<br />
-<br />
+<pre class="prettyprint lang-config">
+# Does the file exist?
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.
+RewriteRule .? - [S=3]
+
 # IF the file exists, then:
-<span class="indent">
-       RewriteRule (.*\.gif) images.php?$1<br />
-       RewriteRule (.*\.html) docs.php?$1<br />
-       # Skip past the "else" stanza.<br />
-       RewriteRule .? - [S=1]<br />
-</span>
+       RewriteRule (.*\.gif) images.php?$1
+       RewriteRule (.*\.html) docs.php?$1
+       # Skip past the "else" stanza.
+       RewriteRule .? - [S=1]
 # ELSE...
-<span class="indent">
-       RewriteRule (.*) 404.php?file=$1<br />
-</span>
+       RewriteRule (.*) 404.php?file=$1
 # END
-</code></p></div>
+</pre>
+
 
 <p>It is probably easier to accomplish this kind of configuration using
 the <code class="directive">&lt;If&gt;</code>, <code class="directive">&lt;ElseIf&gt;</code>, and <code class="directive">&lt;Else&gt;</code> directives instead.</p>
@@ -695,19 +688,21 @@ sent. This has the same effect as the <code class="directive"><a href="../mod/mo
 <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<br />
+<pre class="prettyprint lang-config">
+# Serve .pl files as plain text
 RewriteRule \.pl$ - [T=text/plain]
-</code></p></div>
+</pre>
+
 
 <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 />
+<pre class="prettyprint lang-config">
+# Files with 'IMG' in the name are jpg images.
 RewriteRule IMG - [T=image/jpg]
-</code></p></div>
+</pre>
+
 
 <p>Please note that this is a trivial example, and could be better done
 using <code class="directive"><a href="../mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code>
index ac2e4a4ec60f80aab17ed0490268b1111a7c4d71..8401ecc892f863b4d81fcd7ff21305cc7d09b138 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
 <?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision : 1325683 -->
+<!-- English Revision: 1325683:1330252 (outdated) -->
 <!-- French translation : Lucien GENTIS -->
 <!-- Reviewed by : Vincent Deffontaines -->
 
index 5aaac0fc8675ccc7e032ca6c835170e209509b1d..ce245b2841ca052c89d1608a46eb15c79f469bd8 100644 (file)
@@ -8,6 +8,6 @@
 
   <variants>
     <variant>en</variant>
-    <variant>fr</variant>
+    <variant outdated="yes">fr</variant>
   </variants>
 </metafile>
index 37c2dd60d8aba62d08603d510ad1c76765d23cc0..8c2041b03eb1ebd609f26c4a703ffd00c8ad267c 100644 (file)
@@ -56,24 +56,26 @@ A number of recipes are provided that describe common scenarios.</p>
       <p>To simply map a URL to another server, we use the [P] flag, as
       follows:</p>
 
-<div class="example"><p><code>
-RewriteEngine  on<br />
-RewriteBase    /products/<br />
-RewriteRule    ^<strong>widget/</strong>(.*)$  <strong>http://product.example.com/widget/</strong>$1  [<strong>P</strong>]<br />
+<pre class="prettyprint lang-config">
+RewriteEngine  on
+RewriteBase    /products/
+RewriteRule    ^<strong>widget/</strong>(.*)$  <strong>http://product.example.com/widget/</strong>$1  [<strong>P</strong>]
 ProxyPassReverse /products/widget/ http://product.example.com/widget/
-</code></p></div>
+</pre>
+
 
    <p>In the second example, we proxy the request only if we can't find
    the resource locally. This can be very useful when you're migrating
    from one server to another, and you're not sure if all the content
    has been migrated yet.</p>
 
-<div class="example"><p><code>
-RewriteCond %{REQUEST_FILENAME}       <strong>!-f</strong><br />
-RewriteCond %{REQUEST_FILENAME}       <strong>!-d</strong><br />
-RewriteRule ^/(.*) http://<strong>old</strong>.example.com/$1 [<strong>P</strong>]<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{REQUEST_FILENAME}       <strong>!-f</strong>
+RewriteCond %{REQUEST_FILENAME}       <strong>!-d</strong>
+RewriteRule ^/(.*) http://<strong>old</strong>.example.com/$1 [<strong>P</strong>]
 ProxyPassReverse / http://old.example.com/
-</code></p></div>
+</pre>
+
     </dd>
 
     <dt>Discussion:</dt>
index d4caa4b176feecdbc8639a145ed432333105fe08..76966b1fe40c39fd5d62f2c786355d3d83f51e16 100644 (file)
@@ -74,10 +74,11 @@ configuration.</div>
       <p>We rewrite the old URL to the new one internally via the
       following rule:</p>
 
-<div class="example"><p><code>
-RewriteEngine  on<br />
+<pre class="prettyprint lang-config">
+RewriteEngine  on
 RewriteRule    ^<strong>/old</strong>\.html$  <strong>/new</strong>.html [PT]
-</code></p></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -105,10 +106,11 @@ RewriteRule    ^<strong>/old</strong>\.html$  <strong>/new</strong>.html [PT]
       <p>We force a HTTP redirect to the new URL which leads to a
       change of the browsers and thus the users view:</p>
 
-<div class="example"><p><code>
-RewriteEngine  on<br />
+<pre class="prettyprint lang-config">
+RewriteEngine  on
 RewriteRule    ^<strong>/foo</strong>\.html$  <strong>bar</strong>.html  [<strong>R</strong>]
-</code></p></div>
+</pre>
+
 </dd>
 
 <dt>Discussion</dt>
@@ -118,9 +120,10 @@ RewriteRule    ^<strong>/foo</strong>\.html$  <strong>bar</strong>.html  [<stron
     use the Redirect directive. mod_rewrite was used in that earlier
     example in order to hide the redirect from the client:</p>
 
-    <div class="example"><p><code>
+    <pre class="prettyprint lang-config">
     Redirect /foo.html /bar.html
-    </code></p></div>
+    </pre>
+
 
     </dd>
   </dl>
@@ -147,18 +150,21 @@ RewriteRule    ^<strong>/foo</strong>\.html$  <strong>bar</strong>.html  [<stron
       to the new server, but you might also consider using the Redirect
       or RedirectMatch directive.</p>
 
-<div class="example"><h3>With mod_rewrite</h3><p><code>
-RewriteEngine on<br />
+<pre class="prettyprint lang-config"><strong>With mod_rewrite</strong>
+RewriteEngine on
 RewriteRule   ^/docs/(.+)  http://new.example.com/docs/$1  [R,L]
-</code></p></div>
+</pre>
+
 
-<div class="example"><h3>With RedirectMatch</h3><p><code>
+<pre class="prettyprint lang-config"><strong>With RedirectMatch</strong>
 RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1
-</code></p></div>
+</pre>
+
 
-<div class="example"><h3>With Redirect</h3><p><code>
+<pre class="prettyprint lang-config"><strong>With Redirect</strong>
 Redirect /docs/ http://new.example.com/docs/
-</code></p></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -188,11 +194,12 @@ Redirect /docs/ http://new.example.com/docs/
       internally leads to the invocation of
       <code>/~quux/foo.cgi</code>.</p>
 
-<div class="example"><p><code>
-RewriteEngine  on<br />
-RewriteBase    /~quux/<br />
+<pre class="prettyprint lang-config">
+RewriteEngine  on
+RewriteBase    /~quux/
 RewriteRule    ^foo\.<strong>html</strong>$  foo.<strong>cgi</strong>  [H=<strong>cgi-script</strong>]
-</code></p></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -219,21 +226,22 @@ RewriteRule    ^foo\.<strong>html</strong>$  foo.<strong>cgi</strong>  [H=<stron
       existence of the new extension. If it exists, we take
       that name, else we rewrite the URL to its original state.</p>
 
-<div class="example"><p><code>
-#   backward compatibility ruleset for<br />
-#   rewriting document.html to document.php<br />
-#   when and only when document.php exists<br />
-&lt;Directory /var/www/htdocs&gt;<br />
+<pre class="prettyprint lang-config">
+#   backward compatibility ruleset for
+#   rewriting document.html to document.php
+#   when and only when document.php exists
+&lt;Directory /var/www/htdocs&gt;
 <span class="indent">
-RewriteEngine on<br />
-RewriteBase /var/www/htdocs<br />
-<br />
-RewriteCond $1.php -f<br />
-RewriteCond $1.html !-f<br />
-RewriteRule ^(.*).html$ $1.php<br />
+RewriteEngine on
+RewriteBase /var/www/htdocs
+
+RewriteCond $1.php -f
+RewriteCond $1.html !-f
+RewriteRule ^(.*).html$ $1.php
 </span>
 &lt;/Directory&gt;
-</code></p></div>
+</pre>
+
     </dd>
 
     <dt>Discussion</dt>
@@ -280,64 +288,61 @@ but rather uses the <code class="directive"><a href="../mod/mod_alias.html#redir
 directive placed in a virtual host for the non-canonical
 hostname(s).</p>
 
-<div class="example"><p><code>
-&lt;VirtualHost *:80&gt;<br />
-<span class="indent">
-  ServerName undesired.example.com<br />
-  ServerAlias example.com notthis.example.com<br />
-<br />
-  Redirect / http://www.example.com/<br />
-</span>
-&lt;/VirtualHost&gt;<br />
-<br />
-&lt;VirtualHost *:80&gt;<br />
-<span class="indent">
-  ServerName www.example.com<br />
-</span>
+<pre class="prettyprint lang-config">
+&lt;VirtualHost *:80&gt;
+  ServerName undesired.example.com
+  ServerAlias example.com notthis.example.com
+
+  Redirect / http://www.example.com/
 &lt;/VirtualHost&gt;
-</code></p></div>
+
+&lt;VirtualHost *:80&gt;
+  ServerName www.example.com
+&lt;/VirtualHost&gt;
+</pre>
+
 
 <p>You can alternatively accomplish this using the
 <code class="directive"><a href="../mod/core.html#if">&lt;If&gt;</a></code>
 directive:</p>
 
-<div class="example"><p><code>
-&lt;If "%{HTTP_HOST} != 'www.example.com'"&gt;<br />
-<span class="indent">
-Redirect / http://www.example.com/
-</span>
+<pre class="prettyprint lang-config">
+&lt;If "%{HTTP_HOST} != 'www.example.com'"&gt;
+       Redirect / http://www.example.com/
 &lt;/If&gt;
-</code></p></div>
+</pre>
+
 
 <p>Or, for example, to redirect a portion of your site to HTTPS, you
 might do the following:</p>
 
-<div class="example"><p><code>
-&lt;If "%{SERVER_PROTOCOL} != 'HTTPS'"&gt;<br />
-<span class="indent">
-Redirect /admin/ https://www.example.com/admin/
-</span>
+<pre class="prettyprint lang-config">
+&lt;If "%{SERVER_PROTOCOL} != 'HTTPS'"&gt;
+       Redirect /admin/ https://www.example.com/admin/
 &lt;/If&gt;
-</code></p></div>
+</pre>
+
 
 <p>If, for whatever reason, you still want to use <code>mod_rewrite</code>
 - if, for example, you need this to work with a larger set of RewriteRules -
 you might use one of the recipes below.</p>
 
 <p>For sites running on a port other than 80:</p>
-<div class="example"><p><code>
-RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]<br />
-RewriteCond %{HTTP_HOST}   !^$<br />
-RewriteCond %{SERVER_PORT} !^80$<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
+RewriteCond %{HTTP_HOST}   !^$
+RewriteCond %{SERVER_PORT} !^80$
 RewriteRule ^/?(.*)         http://www.example.com:%{SERVER_PORT}/$1 [L,R,NE]
-</code></p></div>
+</pre>
+
 
 <p>And for a site running on port 80</p>
-<div class="example"><p><code>
-RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]<br />
-RewriteCond %{HTTP_HOST}   !^$<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
+RewriteCond %{HTTP_HOST}   !^$
 RewriteRule ^/?(.*)         http://www.example.com/$1 [L,R,NE]
-</code></p></div>
+</pre>
+
 
         <p>
         If you wanted to do this generically for all domain names - that
@@ -346,11 +351,12 @@ RewriteRule ^/?(.*)         http://www.example.com/$1 [L,R,NE]
         <strong>example.com</strong>, you could use the following
         recipe:</p>
 
-<div class="example"><p><code>
-RewriteCond %{HTTP_HOST} !^www\. [NC]<br />
-RewriteCond %{HTTP_HOST} !^$<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_HOST} !^www\. [NC]
+RewriteCond %{HTTP_HOST} !^$
 RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]
-</code></p></div>
+</pre>
+
 
     <p>These rulesets will work either in your main server configuration
     file, or in a <code>.htaccess</code> file placed in the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> of the server.</p>
@@ -380,23 +386,24 @@ RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]
       resource, and, if not finding it in either place, will attempt to
       just serve it out of the location requested.</p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
-<br />
-#   first try to find it in dir1/...<br />
-#   ...and if found stop and be happy:<br />
-RewriteCond         %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}  -f<br />
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1  [L]<br />
-<br />
-#   second try to find it in dir2/...<br />
-#   ...and if found stop and be happy:<br />
-RewriteCond         %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}  -f<br />
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1  [L]<br />
-<br />
-#   else go on for other Alias or ScriptAlias directives,<br />
-#   etc.<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
+
+#   first try to find it in dir1/...
+#   ...and if found stop and be happy:
+RewriteCond         %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}  -f
+RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1  [L]
+
+#   second try to find it in dir2/...
+#   ...and if found stop and be happy:
+RewriteCond         %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}  -f
+RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1  [L]
+
+#   else go on for other Alias or ScriptAlias directives,
+#   etc.
 RewriteRule   ^  -  [PT]
-</code></p></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -424,13 +431,14 @@ RewriteRule   ^  -  [PT]
     <p>We'll use a <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"><p><code>
-HostnameLookups on<br />
-RewriteEngine on<br />
-RewriteMap    multiplex         txt:/path/to/map.mirrors<br />
-RewriteCond  %{REMOTE_HOST}     ([a-z]+)$ [NC]<br />
+<pre class="prettyprint lang-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]
-</code></p></div>
+</pre>
+
 
 <div class="example"><p><code>
 ##  map.mirrors -- Multiplexing Map<br />
@@ -484,16 +492,17 @@ com       http://www.example.com/<br />
       All other browsers receive page <code>foo.32.html</code>.
       This is done with the following ruleset:</p>
 
-<div class="example"><p><code>
-RewriteCond %{HTTP_USER_AGENT}  ^<strong>Mozilla/3</strong>.*<br />
-RewriteRule ^foo\.html$         foo.<strong>NS</strong>.html          [<strong>L</strong>]<br />
-<br />
-RewriteCond %{HTTP_USER_AGENT}  ^<strong>Lynx/</strong>         [OR]<br />
-RewriteCond %{HTTP_USER_AGENT}  ^<strong>Mozilla/[12]</strong><br />
-RewriteRule ^foo\.html$         foo.<strong>20</strong>.html          [<strong>L</strong>]<br />
-<br />
+<pre class="prettyprint lang-config">
+RewriteCond %{HTTP_USER_AGENT}  ^<strong>Mozilla/3</strong>.*
+RewriteRule ^foo\.html$         foo.<strong>NS</strong>.html          [<strong>L</strong>]
+
+RewriteCond %{HTTP_USER_AGENT}  ^<strong>Lynx/</strong>         [OR]
+RewriteCond %{HTTP_USER_AGENT}  ^<strong>Mozilla/[12]</strong>
+RewriteRule ^foo\.html$         foo.<strong>20</strong>.html          [<strong>L</strong>]
+
 RewriteRule ^foo\.html$         foo.<strong>32</strong>.html          [<strong>L</strong>]
-</code></p></div>
+</pre>
+
     </dd>
   </dl>
 
@@ -524,9 +533,8 @@ RewriteRule ^foo\.html$         foo.<strong>32</strong>.html          [<strong>L
        we replace <code>/puppies</code> and <code>/canines</code>
        by the canonical <code>/dogs</code>.</p>
 
-<div class="example"><p><code>
-RewriteRule   ^/(puppies|canines)/(.*)    /dogs/$2  [R]
-</code></p></div>
+<pre class="prettyprint lang-config">RewriteRule   ^/(puppies|canines)/(.*)    /dogs/$2  [R]</pre>
+
         </dd>
 
      <dt>Discussion:</dt>
@@ -534,9 +542,8 @@ RewriteRule   ^/(puppies|canines)/(.*)    /dogs/$2  [R]
      This should really be accomplished with Redirect or RedirectMatch
      directives:
 
-     <div class="example"><p><code>
-     RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2
-     </code></p></div>
+     <pre class="prettyprint lang-config"> RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2 </pre>
+
      </dd>
       </dl>
 
@@ -565,16 +572,16 @@ using the following ruleset:</p>
       <code>/about/</code>:
       </p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
 RewriteRule   <strong>^/$</strong>  /about/  [<strong>R</strong>]
-</code></p></div>
+</pre>
+
 
 <p>Note that this can also be handled using the <code class="directive"><a href="../mod/mod_alias.html#redirectmatch">RedirectMatch</a></code> directive:</p>
 
-<div class="example"><p><code>
-RedirectMatch ^/$ http://example.com/about/
-</code></p></div>
+<pre class="prettyprint lang-config">RedirectMatch ^/$ http://example.com/about/</pre>
+
 
 <p>Note also that the example rewrites only the root URL. That is, it
 rewrites a request for <code>http://example.com/</code>, but not a
@@ -602,36 +609,33 @@ that should go to an existing resource such as an image, or a css file.</dd>
 <dd>
 <p>As of version 2.2.16, you should use the <code class="directive"><a href="../mod/mod_dir.html#fallbackresource">FallbackResource</a></code> directive for this:</p>
 
-<div class="example"><p><code>
-&lt;Directory /var/www/my_blog&gt;<br />
-<span class="indent">
-  FallbackResource index.php<br />
-</span>
+<pre class="prettyprint lang-config">
+&lt;Directory /var/www/my_blog&gt;
+  FallbackResource index.php
 &lt;/Directory&gt;
-</code></p></div>
+</pre>
+
 
 <p>However, in earlier versions of Apache, or if your needs are more
 complicated than this, you can use a variation of the following rewrite
 set to accomplish the same thing:</p>
 
-<div class="example"><p><code>
-&lt;Directory /var/www/my_blog&gt;<br />
-<span class="indent">
-  RewriteBase /my_blog<br />
-<br />
-  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f<br />
-  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d<br />
-  RewriteRule ^ index.php [PT]<br />
-</span>
+<pre class="prettyprint lang-config">
+&lt;Directory /var/www/my_blog&gt;
+  RewriteBase /my_blog
+
+  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f
+  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d
+  RewriteRule ^ index.php [PT]
 &lt;/Directory&gt;
-</code></p></div>
+</pre>
+
 
 <p>If, on the other hand, you wish to pass the requested URI as a query
 string argument to index.php, you can replace that RewriteRule with:</p>
 
-<div class="example"><p><code>
-  RewriteRule (.*) index.php?$1 [PT,QSA]
-</code></p></div>
+<pre class="prettyprint lang-config">RewriteRule (.*) index.php?$1 [PT,QSA]</pre>
+
 
 <p>Note that these rulesets can be used in a <code>.htaccess</code>
 file, as well as in a &lt;Directory&gt; block.</p>
index e540e23421479cd4cff088d68be5ca445720e96d..3e4f62429b9eb6fe3f09594504483bc8493defd8 100644 (file)
@@ -64,9 +64,8 @@ configuration.</div>
    <p>The syntax of the <code>RewriteMap</code> directive is as
    follows:</p>
 
-<div class="example"><p><code>
-RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
-</code></p></div>
+<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em></pre>
+
 
     <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is an
     arbitray name that you assign to the map, and which you will use in
@@ -90,21 +89,18 @@ RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
 
     <p>For example, you might define a
       <code class="directive">RewriteMap</code> as:</p>
-    <div class="example"><p><code>
-      RewriteMap examplemap txt:/path/to/file/map.txt
-      </code></p></div>
+    <pre class="prettyprint lang-config">RewriteMap examplemap txt:/path/to/file/map.txt</pre>
+
     <p>You would then be able to use this map in a
       <code class="directive">RewriteRule</code> as follows:</p>
-<div class="example"><p><code>
-  RewriteRule ^/ex/(.*) ${examplemap:$1}
-</code></p></div>
+<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1}</pre>
+
 
 <p>A default value can be specified in the event that nothing is found
 in the map:</p>
 
-<div class="example"><p><code>
-RewriteRule ^/ex/(.*) ${examplemap:$1|/not_found.html}
-</code></p></div>
+<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1|/not_found.html}</pre>
+
 
 <div class="note"><h3>Per-directory and .htaccess context</h3>
 <p>
@@ -146,10 +142,11 @@ may be used, and give examples of each.</p>
     product IDs for easier-to-remember URLs, using the following
     recipe:</p>
 
-    <div class="example"><h3>Product to ID configuration</h3><p><code>
-    RewriteMap product2id txt:/etc/apache2/productmap.txt<br />
+    <pre class="prettyprint lang-config"><strong>#Product to ID configuration</strong>
+    RewriteMap product2id txt:/etc/apache2/productmap.txt
     RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]
-    </code></p></div>
+    </pre>
+
 
     <p>We assume here that the <code>prods.php</code> script knows what
     to do when it received an argument of <code>id=NOTFOUND</code> when
@@ -179,9 +176,8 @@ telephone  328
     scope. If you're planning to use this in a <code>.htaccess</code>
     file, you'll need to remove the leading slash from the rewrite
     pattern in order for it to match anything:
-    <div class="example"><p><code>
-    RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]
-    </code></p></div>
+    <pre class="prettyprint lang-config">RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre>
+
     </div>
 
     <div class="note"><h3>Cached lookups</h3>
@@ -219,12 +215,13 @@ static   www1|www2|www3|www4<br />
 dynamic  www5|www6
     </code></p></div>
 
-    <div class="example"><h3>Configuration directives</h3><p><code>
-    RewriteMap servers rnd:/path/to/file/map.txt<br />
-    <br />
-    RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L]<br />
-    RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]
-    </code></p></div>
+    <pre class="prettyprint lang-config"><strong>#Configuration directives</strong>
+RewriteMap servers rnd:/path/to/file/map.txt
+
+RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L]
+RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]
+    </pre>
+
 
     <p>So, when an image is requested and the first of these rules is
     matched, <code>RewriteMap</code> looks up the string
@@ -255,9 +252,10 @@ static   www1|www1|www2|www3|www4
 
     <p>You may optionally specify a particular dbm type:</p>
 
- <div class="example"><p><code>
- RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm
- </code></p></div>
+ <pre class="prettyprint lang-config">
+RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm
+ </pre>
+
 
     <p>The type can be sdbm, gdbm, ndbm or db.
     However, it is recommended that you just use the <a href="../programs/httxt2dbm.html">httxt2dbm</a> utility that is
@@ -275,9 +273,10 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map
 <p>You can then reference the resulting file in your
 <code>RewriteMap</code> directive:</p>
 
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
 RewriteMap mapname dbm:/etc/apache/mapfile.map
-</code></p></div>
+</pre>
+
 
 <div class="note">
 <p>Note that with some dbm types, more than one file is generated, with
@@ -326,10 +325,11 @@ by many requests.
     the int function, and then use that in your <code>RewriteRule</code>:
     </p>
 
-    <div class="example"><h3>Redirect a URI to an all-lowercase version of itself</h3><p><code>
-    RewriteMap lc int:tolower<br />
+    <pre class="prettyprint lang-config"><strong>Redirect a URI to an all-lowercase version of itself</strong>
+    RewriteMap lc int:tolower
     RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]
-    </code></p></div>
+    </pre>
+
 
     <div class="note">
     <p>Please note that the example offered here is for
@@ -369,12 +369,13 @@ by many requests.
     <p>A simple example is shown here which will replace all dashes with
     underscores in a request URI.</p>
 
-    <div class="example"><h3>Rewrite configuration</h3><p><code>
-    RewriteMap d2u prg:/www/bin/dash2under.pl<br />
-    RewriteRule - ${d2u:%{REQUEST_URI}}
-    </code></p></div>
+    <pre class="prettyprint lang-config"><strong>#Rewrite configuration</strong>
+RewriteMap d2u prg:/www/bin/dash2under.pl<br />
+RewriteRule - ${d2u:%{REQUEST_URI}}
+    </pre>
+
 
-    <div class="example"><h3>dash2under.pl</h3><p><code>
+    <p><strong>dash2under.pl</strong></p>
     <pre class="prettyprint lang-perl">
     #!/usr/bin/perl
     $| = 1; # Turn off I/O buffering
@@ -384,7 +385,6 @@ by many requests.
     }
     </pre>
 
-    </code></p></div>
 
 <div class="note"><h3>Caution!</h3>
 <ul>
@@ -426,9 +426,10 @@ this process, or if the script itself is very slow.</li>
     <p>If a query returns more than one row, a random row from
 the result set is used.</p>
 
-    <div class="example"><h3>Example</h3><p><code>
+    <pre class="prettyprint lang-config"><strong>Example</strong>
 RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s"
-    </code></p></div>
+    </pre>
+
 
   </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
index 915df204c3461b9efd1012a2f37453523b617378..4025a8484244ff565f2f8284f6f2be21886b95b1 100644 (file)
@@ -65,14 +65,15 @@ mod_rewrite</a> document.</div>
 
     <dd>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
-<br />
-RewriteMap    lowercase int:tolower<br />
-<br />
-RewriteCond   %{lowercase:%{<strong>HTTP_HOST</strong>}}   ^www\.<strong>([^.]+)</strong>\.example\.com$<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
+
+RewriteMap    lowercase int:tolower
+
+RewriteCond   %{lowercase:%{<strong>HTTP_HOST</strong>}}   ^www\.<strong>([^.]+)</strong>\.example\.com$
 RewriteRule   ^(.*) /home/<strong>%1</strong>/www$1
-</code></p></div></dd>
+</pre>
+</dd>
 
 <dt>Discussion</dt>
     <dd>
@@ -122,39 +123,38 @@ dynamic content, and Alias resolution.
     any <code>ScriptAlias</code> directives, we must have
     <code>mod_rewrite</code> explicitly enact those mappings.</p>
 
-<div class="example"><p><code>
-# get the server name from the Host: header<br />
-UseCanonicalName Off<br />
-<br />
-# splittable logs<br />
-LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon<br />
-CustomLog logs/access_log vcommon<br />
-<br />
-&lt;Directory /www/hosts&gt;<br />
-<span class="indent">
-    # ExecCGI is needed here because we can't force<br />
-    # CGI execution in the way that ScriptAlias does<br />
-    Options FollowSymLinks ExecCGI<br />
-</span>
-&lt;/Directory&gt;<br />
-<br />
-RewriteEngine On<br />
-<br />
-# a ServerName derived from a Host: header may be any case at all<br />
-RewriteMap  lowercase  int:tolower<br />
-<br />
-## deal with normal documents first:<br />
-# allow Alias /icons/ to work - repeat for other aliases<br />
-RewriteCond  %{REQUEST_URI}  !^/icons/<br />
-# allow CGIs to work<br />
-RewriteCond  %{REQUEST_URI}  !^/cgi-bin/<br />
-# do the magic<br />
-RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1<br />
-<br />
-## and now deal with CGIs - we have to force a handler<br />
-RewriteCond  %{REQUEST_URI}  ^/cgi-bin/<br />
-RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1  [H=cgi-script]<br />
-</code></p></div>
+<pre class="prettyprint lang-config">
+# get the server name from the Host: header
+UseCanonicalName Off
+
+# splittable logs
+LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
+CustomLog logs/access_log vcommon
+
+&lt;Directory /www/hosts&gt;
+    # ExecCGI is needed here because we can't force
+    # CGI execution in the way that ScriptAlias does
+    Options FollowSymLinks ExecCGI
+&lt;/Directory&gt;
+
+RewriteEngine On
+
+# a ServerName derived from a Host: header may be any case at all
+RewriteMap  lowercase  int:tolower
+
+## deal with normal documents first:
+# allow Alias /icons/ to work - repeat for other aliases
+RewriteCond  %{REQUEST_URI}  !^/icons/
+# allow CGIs to work
+RewriteCond  %{REQUEST_URI}  !^/cgi-bin/
+# do the magic
+RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1
+
+## and now deal with CGIs - we have to force a handler
+RewriteCond  %{REQUEST_URI}  ^/cgi-bin/
+RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1  [H=cgi-script]
+</pre>
+
 
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
@@ -177,27 +177,28 @@ customer-N.example.com  /www/customers/N<br />
 
     <p>The <code>httpd.conf</code> should contain the following:</p>
 
-<div class="example"><p><code>
-RewriteEngine on<br />
-<br />
-RewriteMap   lowercase  int:tolower<br />
-<br />
-# define the map file<br />
-RewriteMap   vhost      txt:/www/conf/vhost.map<br />
-<br />
-# deal with aliases as above<br />
-RewriteCond  %{REQUEST_URI}               !^/icons/<br />
-RewriteCond  %{REQUEST_URI}               !^/cgi-bin/<br />
-RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$<br />
-# this does the file-based remap<br />
-RewriteCond  ${vhost:%1}                  ^(/.*)$<br />
-RewriteRule  ^/(.*)$                      %1/docs/$1<br />
-<br />
-RewriteCond  %{REQUEST_URI}               ^/cgi-bin/<br />
-RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$<br />
-RewriteCond  ${vhost:%1}                  ^(/.*)$<br />
+<pre class="prettyprint lang-config">
+RewriteEngine on
+
+RewriteMap   lowercase  int:tolower
+
+# define the map file
+RewriteMap   vhost      txt:/www/conf/vhost.map
+
+# deal with aliases as above
+RewriteCond  %{REQUEST_URI}               !^/icons/
+RewriteCond  %{REQUEST_URI}               !^/cgi-bin/
+RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$
+# this does the file-based remap
+RewriteCond  ${vhost:%1}                  ^(/.*)$
+RewriteRule  ^/(.*)$                      %1/docs/$1
+
+RewriteCond  %{REQUEST_URI}               ^/cgi-bin/
+RewriteCond  ${lowercase:%{SERVER_NAME}}  ^(.+)$
+RewriteCond  ${vhost:%1}                  ^(/.*)$
 RewriteRule  ^/(.*)$                      %1/cgi-bin/$1 [H=cgi-script]
-</code></p></div>
+</pre>
+
 
 </div></div>
 <div class="bottomlang">