Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 84162 invoked from network); 14 Jan 2011 21:18:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jan 2011 21:18:59 -0000 Received: (qmail 35897 invoked by uid 500); 14 Jan 2011 21:18:59 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 35849 invoked by uid 500); 14 Jan 2011 21:18:59 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 35842 invoked by uid 99); 14 Jan 2011 21:18:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Jan 2011 21:18:59 +0000 X-ASF-Spam-Status: No, hits=-1996.9 required=10.0 tests=ALL_TRUSTED,URI_OBFU_WWW X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Jan 2011 21:18:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BC8EF2388A2C; Fri, 14 Jan 2011 21:18:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1059175 - in /httpd/httpd/trunk/docs/manual/rewrite: advanced.html.en proxy.html.en remapping.html.en rewritemap.html.en Date: Fri, 14 Jan 2011 21:18:27 -0000 To: cvs@httpd.apache.org From: rbowen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110114211827.BC8EF2388A2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rbowen Date: Fri Jan 14 21:18:27 2011 New Revision: 1059175 URL: http://svn.apache.org/viewvc?rev=1059175&view=rev Log: Rebuild HTML. Modified: httpd/httpd/trunk/docs/manual/rewrite/advanced.html.en httpd/httpd/trunk/docs/manual/rewrite/proxy.html.en httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en httpd/httpd/trunk/docs/manual/rewrite/rewritemap.html.en Modified: httpd/httpd/trunk/docs/manual/rewrite/advanced.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/advanced.html.en?rev=1059175&r1=1059174&r2=1059175&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/advanced.html.en (original) +++ httpd/httpd/trunk/docs/manual/rewrite/advanced.html.en Fri Jan 14 21:18:27 2011 @@ -64,37 +64,37 @@ configuration.

A mapping is maintained, from users to target servers, in external map files. They look like:

-
-user1  physical_host_of_user1
-user2  physical_host_of_user2
+

+user1 physical_host_of_user1
+user2 physical_host_of_user2
: : -

+

We put this into a map.users-to-hosts file. The aim is to map;

-
+

/u/user1/anypath -

+

to

-
+

http://physical_host_of_user1/u/user/anypath -

+

thus every URL path need not be valid on every backend physical host. The following ruleset does this for us with the help of the map files assuming that server0 is a default server which will be used if a user has no entry in the map:

-
-RewriteEngine on
-
-RewriteMap      users-to-hosts   txt:/path/to/map.users-to-hosts
-
+

+RewriteEngine on
+
+RewriteMap users-to-hosts txt:/path/to/map.users-to-hosts
+
RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2 -

+

@@ -120,11 +120,11 @@ RewriteRule ^/u/([^/]+) This is done via the following ruleset: -
-# This example is valid in per-directory context only
-RewriteCond %{REQUEST_FILENAME}   !-s
+

+# This example is valid in per-directory context only
+RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^page\.html$ page.cgi [T=application/x-httpd-cgi,L] -

+

Here a request for page.html leads to an internal run of a corresponding page.cgi if @@ -159,20 +159,20 @@ RewriteRule ^page\.html

We'll use RewriteMap and a list of servers to accomplish this.

-
-RewriteEngine on
-RewriteMap lb rnd:/path/to/serverlist.txt
-
+

+RewriteEngine on
+RewriteMap lb rnd:/path/to/serverlist.txt
+
RewriteRule ^/(.*) http://${lb:servers}/$1 [P,L] -

+

serverlist.txt will contain a list of the servers:

-
-## serverlist.txt
-
-servers one.example.com|two.example.com|three.example.com
-
+

+## serverlist.txt
+
+servers one.example.com|two.example.com|three.example.com
+

If you want one particular server to get more of the load than the others, add it more times to the list.

@@ -213,21 +213,21 @@ featureful than anything you can cobble URL causes the 'page' to be refreshed every time it is updated on the filesystem.

-
+

RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1 -

+

Now when we reference the URL

-
+

/u/foo/bar/page.html:refresh -

+

this leads to the internal invocation of the URL

-
+

/internal/cgi/apache/nph-refresh?f=/u/foo/bar/page.html -

+

The only missing part is the NPH-CGI script. Although one would usually say "left as an exercise to the reader" @@ -364,10 +364,10 @@ exit(0);

We use the following ruleset to expand the tilde URLs into the above layout.

-
-RewriteEngine on
+

+RewriteEngine on
RewriteRule ^/~(([a-z])[a-z0-9]+)(.*) /home/$2/$1/public_html$3 -

+

@@ -423,13 +423,13 @@ RewriteRule ^/~(([a-z])>STRING and =STRING we can do time-dependent redirects:

-
-RewriteEngine on
-RewriteCond   %{TIME_HOUR}%{TIME_MIN} >0700
-RewriteCond   %{TIME_HOUR}%{TIME_MIN} <1900
-RewriteRule   ^foo\.html$             foo.day.html [L]
+

+RewriteEngine on
+RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700
+RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900
+RewriteRule ^foo\.html$ foo.day.html [L]
RewriteRule ^foo\.html$ foo.night.html -

+

This provides the content of foo.day.html under the URL foo.html from @@ -468,17 +468,17 @@ RewriteRule ^foo\.html$ fo

Use the [E] flag to set an environment variable.

-
-RewriteEngine on
+

+RewriteEngine on
RewriteRule ^/horse/(.*) /pony/$1 [E=rewritten:1] -

+

Later in your ruleset you might check for this environment variable using a RewriteCond:

-
+

RewriteCond %{ENV:rewritten} =1 -

+

Modified: httpd/httpd/trunk/docs/manual/rewrite/proxy.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/proxy.html.en?rev=1059175&r1=1059174&r2=1059175&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/proxy.html.en (original) +++ httpd/httpd/trunk/docs/manual/rewrite/proxy.html.en Fri Jan 14 21:18:27 2011 @@ -53,24 +53,24 @@ A number of recipes are provided that de

To simply map a URL to another server, we use the [P] flag, as follows:

-
-RewriteEngine  on
-RewriteBase    /products/
-RewriteRule    ^widget/(.*)$  http://product.example.com/widget/$1  [P]
+

+RewriteEngine on
+RewriteBase /products/
+RewriteRule ^widget/(.*)$ http://product.example.com/widget/$1 [P]
ProxyPassReverse /products/widget/ http://product.example.com/widget/ -

+

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.

-
-RewriteCond %{REQUEST_FILENAME}       !-f
-RewriteCond %{REQUEST_FILENAME}       !-d
-RewriteRule ^/(.*) http://old.example.com$1 [P]
+

+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule ^/(.*) http://old.example.com$1 [P]
ProxyPassReverse / http://old.example.com/ -

+

Discussion:
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=1059175&r1=1059174&r2=1059175&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en (original) +++ httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en Fri Jan 14 21:18:27 2011 @@ -71,10 +71,10 @@ configuration.

We rewrite the old URL to the new one internally via the following rule:

-
-RewriteEngine  on
+

+RewriteEngine on
RewriteRule ^/old\.html$ /new.html [PT] -

+

@@ -102,10 +102,10 @@ RewriteRule ^/old\.h

We force a HTTP redirect to the new URL which leads to a change of the browsers and thus the users view:

-
-RewriteEngine  on
+

+RewriteEngine on
RewriteRule ^/foo\.html$ bar.html [R] -

+

Discussion
@@ -144,18 +144,18 @@ RewriteRule ^/foo\.h to the new server, but you might also consider using the Redirect or RedirectMatch directive.

-

With mod_rewrite

-RewriteEngine on
+

With mod_rewrite

+RewriteEngine on
RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L] -

+

-

With RedirectMatch

+

With RedirectMatch

RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1 -

+

-

With Redirect

+

With Redirect

Redirect /docs/ http://new.example.com/docs/ -

+

@@ -185,11 +185,11 @@ Redirect /docs/ http://new.example.com/d internally leads to the invocation of /~quux/foo.cgi.

-
-RewriteEngine  on
-RewriteBase    /~quux/
+

+RewriteEngine on
+RewriteBase /~quux/
RewriteRule ^foo\.html$ foo.cgi [H=cgi-script] -

+

@@ -216,19 +216,21 @@ RewriteRule ^foo\.html -
-#   backward compatibility ruleset for
-#   rewriting document.html to document.php
-#   when and only when document.php exists
-<Directory /var/www/htdocs>
-RewriteEngine on
-RewriteBase /var/www/htdocs
-
-RewriteCond $1.php -f
-RewriteCond $1.html !-f
-RewriteRule ^(.*).html$ $1.php
+

+# backward compatibility ruleset for
+# rewriting document.html to document.php
+# when and only when document.php exists
+<Directory /var/www/htdocs>
+ +RewriteEngine on
+RewriteBase /var/www/htdocs
+
+RewriteCond $1.php -f
+RewriteCond $1.html !-f
+RewriteRule ^(.*).html$ $1.php
+
</Directory> -

+

Discussion
@@ -320,19 +322,19 @@ Redirect /admin/ https://www.example.com you might use one of the recipes below.

For sites running on a port other than 80:

-
-RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
-RewriteCond %{HTTP_HOST}   !^$
-RewriteCond %{SERVER_PORT} !^80$
+

+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] -

+

And for a site running on port 80

-
-RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
-RewriteCond %{HTTP_HOST}   !^$
+

+RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
+RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE] -

+

If you wanted to do this generically for all domain names - that @@ -341,11 +343,11 @@ RewriteRule ^/?(.*) http://www.e example.com, you could use the following recipe:

-
-RewriteCond %{HTTP_HOST} !^www\. [NC]
-RewriteCond %{HTTP_HOST} !^$
+

+RewriteCond %{HTTP_HOST} !^www\. [NC]
+RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] -

+

These rulesets will work either in your main server configuration file, or in a .htaccess file placed in the DocumentRoot of the server.

@@ -375,23 +377,23 @@ RewriteRule ^/?(.*) http://www.%{HTTP_HO resource, and, if not finding it in either place, will attempt to just serve it out of the location requested.

-
-RewriteEngine on
-
-#   first try to find it in dir1/...
-#   ...and if found stop and be happy:
-RewriteCond         %{DOCUMENT_ROOT}/dir1/%{REQUEST_URI}  -f
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/dir1/$1  [L]
-
-#   second try to find it in dir2/...
-#   ...and if found stop and be happy:
-RewriteCond         %{DOCUMENT_ROOT}/dir2/%{REQUEST_URI}  -f
-RewriteRule  ^(.+)  %{DOCUMENT_ROOT}/dir2/$1  [L]
-
-#   else go on for other Alias or ScriptAlias directives,
-#   etc.
+

+RewriteEngine on
+
+# first try to find it in dir1/...
+# ...and if found stop and be happy:
+RewriteCond %{DOCUMENT_ROOT}/dir1/%{REQUEST_URI} -f
+RewriteRule ^(.+) %{DOCUMENT_ROOT}/dir1/$1 [L]
+
+# second try to find it in dir2/...
+# ...and if found stop and be happy:
+RewriteCond %{DOCUMENT_ROOT}/dir2/%{REQUEST_URI} -f
+RewriteRule ^(.+) %{DOCUMENT_ROOT}/dir2/$1 [L]
+
+# else go on for other Alias or ScriptAlias directives,
+# etc.
RewriteRule ^ - [PT] -

+

@@ -419,22 +421,22 @@ RewriteRule ^ - [PT]

We'll use a RewriteMap directive to build a list of servers that we wish to use.

-
-HostnameLookups on
-RewriteEngine on
-RewriteMap    multiplex         txt:/path/to/map.mirrors
-RewriteCond  %{REMOTE_HOST}     ([a-z]+)$ [NC]
+

+HostnameLookups on
+RewriteEngine on
+RewriteMap multiplex txt:/path/to/map.mirrors
+RewriteCond %{REMOTE_HOST} ([a-z]+)$ [NC]
RewriteRule ^/(.*)$ ${multiplex:%1|http://www.example.com/}$1 [R,L] -

- -
-##  map.mirrors -- Multiplexing Map
+

-de http://www.example.de/ -uk http://www.example.uk/ -com http://www.example.com/ +

+## map.mirrors -- Multiplexing Map
+
+de http://www.example.de/
+uk http://www.example.uk/
+com http://www.example.com/
##EOF## -

+

Discussion
@@ -479,16 +481,16 @@ com http://www.example.com/ All other browsers receive page foo.32.html. This is done with the following ruleset:

-
-RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/3.*
-RewriteRule ^foo\.html$         foo.NS.html          [L]
-
-RewriteCond %{HTTP_USER_AGENT}  ^Lynx/.*         [OR]
-RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/[12].*
-RewriteRule ^foo\.html$         foo.20.html          [L]
-
+

+RewriteCond %{HTTP_USER_AGENT} ^Mozilla/3.*
+RewriteRule ^foo\.html$ foo.NS.html [L]
+
+RewriteCond %{HTTP_USER_AGENT} ^Lynx/.* [OR]
+RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[12].*
+RewriteRule ^foo\.html$ foo.20.html [L]
+
RewriteRule ^foo\.html$ foo.32.html [L] -

+

@@ -519,9 +521,9 @@ RewriteRule ^foo\.html$ foo./puppies and /canines by the canonical /dogs.

-
+

RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R] -

+

Discussion:
@@ -529,9 +531,9 @@ RewriteRule ^/(puppies|canines)/(.*) This should really be accomplished with Redirect or RedirectMatch directives: -
+     

RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2 -

+

@@ -560,10 +562,10 @@ using the following ruleset:

/about/:

-
-RewriteEngine on
+

+RewriteEngine on
RewriteRule ^/$ /about/ [R] -

+

Note that this can also be handled using the RedirectMatch directive:

@@ -597,32 +599,36 @@ that should go to an existing resource s

As of version 2.2.16, you should use the FallbackResource directive for this:

-
-<Directory /var/www/my_blog>
-  FallbackResource index.php
+

+<Directory /var/www/my_blog>
+ + FallbackResource index.php
+
</Directory> -

+

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:

-
-<Directory /var/www/my_blog>
-  RewriteBase /my_blog
-
-  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f
-  RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d
-  RewriteRule ^ index.php [PT]
+

+<Directory /var/www/my_blog>
+ + RewriteBase /my_blog
+
+ RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f
+ RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d
+ RewriteRule ^ index.php [PT]
+
</Directory> -

+

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:

-
+

RewriteRule (.*) index.php?$1 [PT,QSA] -

+

Note that these rulesets can be uses in a .htaccess file, as well as in a <Directory> block.

Modified: httpd/httpd/trunk/docs/manual/rewrite/rewritemap.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/rewritemap.html.en?rev=1059175&r1=1059174&r2=1059175&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/rewritemap.html.en (original) +++ httpd/httpd/trunk/docs/manual/rewrite/rewritemap.html.en Fri Jan 14 21:18:27 2011 @@ -155,17 +155,17 @@ may be used, and give examples of each.<

The file /etc/apache2/productmap.txt then contains the following:

-

Product to ID map

-##
-##  productmap.txt - Product to ID map file
-##
-
-television 993
-stereo     198
-fishingrod 043
-basketball 418
+    

Product to ID map

+##
+## productmap.txt - Product to ID map file
+##
+
+television 993
+stereo 198
+fishingrod 043
+basketball 418
telephone 328 -

+

Thus, when http://example.com/product/television is requested, the RewriteRule is applied, and the request @@ -207,14 +207,14 @@ telephone 328 to one of the servers in the 'static' pool, while everything else is sent to one of the 'dynamic' pool.

-

Rewrite map file

-##
-##  map.txt -- rewriting map
-##
-
-static   www1|www2|www3|www4
+    

Rewrite map file

+##
+## map.txt -- rewriting map
+##
+
+static www1|www2|www3|www4
dynamic www5|www6 -

+

Configuration directives

RewriteMap servers rnd:/path/to/file/map.txt