From: Daniel Gruno Date: Thu, 19 Jul 2012 15:07:53 +0000 (+0000) Subject: xforms X-Git-Tag: 2.2.23~118 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f30bbb6fbc293befc6885c497a62aa11fb45c790;p=thirdparty%2Fapache%2Fhttpd.git xforms git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1363365 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/advanced.html.en b/docs/manual/rewrite/advanced.html.en index 3fe073071c1..b94b519076c 100644 --- a/docs/manual/rewrite/advanced.html.en +++ b/docs/manual/rewrite/advanced.html.en @@ -25,8 +25,8 @@ -

This document supplements the mod_rewrite -reference documentation. It provides +

This document supplements the mod_rewrite +reference documentation. It provides a few advanced techniques and tricks using mod_rewrite.

Note that many of these examples won't work unchanged in your @@ -54,8 +54,8 @@ configuration.
Description:
-

A common technique for distributing the burden of - server load or storage space is called "sharding". +

A common technique for distributing the burden of + server load or storage space is called "sharding". When using this method, a front-end server will use the url to consistently "shard" users or objects to separate backend servers.

@@ -101,6 +101,9 @@ RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hos
+

See the RewriteMap + documentation for more discussion of the syntax of this directive.

+
top

On-the-fly Content-Regeneration

@@ -123,22 +126,25 @@ RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hos
This is done via the following ruleset: -

-# 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 - page.html is missing or has filesize - null. The trick here is that page.cgi is a - CGI script which (additionally to its STDOUT) - writes its output to the file page.html. - Once it has completed, the server sends out - page.html. When the webmaster wants to force - a refresh of the contents, he just removes - page.html (typically from cron).

+
+# This example is valid in per-directory context only
+RewriteCond %{REQUEST_URI}   !-U
+RewriteRule ^(.+)\.html$          /regenerate_page.cgi   [PT,L]
+
+ + +

The -U operator determines whether the test string + (in this case, REQUEST_URI) is a valid URL. It does + this via a subrequest. In the event that this subrequest fails - + that is, the requested resource doesn't exist - this rule invokes + the CGI program /regenerate_page.cgi, which generates + the requested resource and saves it into the document directory, so + that the next time it is requested, a static copy can be served.

+ +

In this way, documents that are infrequently updated can be served in + static form. if documents need to be refreshed, they can be deleted + from the document directory, and they will then be regenerated the + next time they are requested.

@@ -245,61 +251,61 @@ RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1 $| = 1; # split the QUERY_STRING variable -@pairs = split(/&/, $ENV{'QUERY_STRING'}); +@pairs = split( /&/, $ENV{'QUERY_STRING'} ); foreach $pair (@pairs) { -($name, $value) = split(/=/, $pair); -$name =~ tr/A-Z/a-z/; -$name = 'QS_' . $name; -$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; -eval "\$$name = \"$value\""; + ( $name, $value ) = split( /=/, $pair ); + $name =~ tr/A-Z/a-z/; + $name = 'QS_' . $name; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + eval "\$$name = \"$value\""; } -$QS_s = 1 if ($QS_s eq ''); -$QS_n = 3600 if ($QS_n eq ''); -if ($QS_f eq '') { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; +$QS_s = 1 if ( $QS_s eq '' ); +$QS_n = 3600 if ( $QS_n eq '' ); +if ( $QS_f eq '' ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; print "<b>ERROR</b>: No file given\n"; -exit(0); + exit(0); } -if (! -f $QS_f) { -print "HTTP/1.0 200 OK\n"; -print "Content-type: text/html\n\n"; +if ( !-f $QS_f ) { + print "HTTP/1.0 200 OK\n"; + print "Content-type: text/html\n\n"; print "<b>ERROR</b>: File $QS_f not found\n"; -exit(0); + exit(0); } sub print_http_headers_multipart_begin { -print "HTTP/1.0 200 OK\n"; -$bound = "ThisRandomString12345"; -print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; -&print_http_headers_multipart_next; + print "HTTP/1.0 200 OK\n"; + $bound = "ThisRandomString12345"; + print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; + &print_http_headers_multipart_next; } sub print_http_headers_multipart_next { -print "\n--$bound\n"; + print "\n--$bound\n"; } sub print_http_headers_multipart_end { -print "\n--$bound--\n"; + print "\n--$bound--\n"; } sub displayhtml { -local($buffer) = @_; -$len = length($buffer); -print "Content-type: text/html\n"; -print "Content-length: $len\n\n"; -print $buffer; + local ($buffer) = @_; + $len = length($buffer); + print "Content-type: text/html\n"; + print "Content-length: $len\n\n"; + print $buffer; } sub readfile { -local($file) = @_; -local(*FP, $size, $buffer, $bytes); -($x, $x, $x, $x, $x, $x, $x, $size) = stat($file); -$size = sprintf("%d", $size); + local ($file) = @_; + local ( *FP, $size, $buffer, $bytes ); + ( $x, $x, $x, $x, $x, $x, $x, $size ) = stat($file); + $size = sprintf( "%d", $size ); open(FP, "<$file"); -$bytes = sysread(FP, $buffer, $size); -close(FP); -return $buffer; + $bytes = sysread( FP, $buffer, $size ); + close(FP); + return $buffer; } $buffer = &readfile($QS_f); @@ -307,30 +313,30 @@ $buffer = &readfile($QS_f); &displayhtml($buffer); sub mystat { -local($file) = $_[0]; -local($time); + local ($file) = $_[0]; + local ($time); -($x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime) = stat($file); -return $mtime; + ( $x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime ) = stat($file); + return $mtime; } $mtimeL = &mystat($QS_f); -$mtime = $mtime; -for ($n = 0; $n < $QS_n; $n++) { -while (1) { - $mtime = &mystat($QS_f); - if ($mtime ne $mtimeL) { - $mtimeL = $mtime; - sleep(2); - $buffer = &readfile($QS_f); - &print_http_headers_multipart_next; - &displayhtml($buffer); - sleep(5); - $mtimeL = &mystat($QS_f); - last; +$mtime = $mtime; +for ( $n = 0 ; $n & lt ; $QS_n ; $n++ ) { + while (1) { + $mtime = &mystat($QS_f); + if ( $mtime ne $mtimeL ) { + $mtimeL = $mtime; + sleep(2); + $buffer = &readfile($QS_f); + &print_http_headers_multipart_next; + &displayhtml($buffer); + sleep(5); + $mtimeL = &mystat($QS_f); + last; + } + sleep($QS_s); } - sleep($QS_s); -} } &print_http_headers_multipart_end; @@ -399,7 +405,7 @@ RewriteRule ^/~(([a-z])[a-z0-9]+)(.*) /home/$2
Discussion:
-
This technique will of course also work with other +
This technique will of course also work with other special characters that mod_rewrite, by default, URL-encodes.
diff --git a/docs/manual/rewrite/flags.html.en b/docs/manual/rewrite/flags.html.en index f3e7919bf9a..23f0f26d2ab 100644 --- a/docs/manual/rewrite/flags.html.en +++ b/docs/manual/rewrite/flags.html.en @@ -49,7 +49,7 @@ providing detailed explanations and examples.

  • R|redirect
  • S|skip
  • T|type
  • -

    See also

    +

    See also

    top

    Introduction

    @@ -65,7 +65,7 @@ RewriteRule pattern target [Flag1,Flag2,Flag3] a longer form, such as cookie. Some flags take one or more arguments. Flags are not case sensitive.

    -

    Each flag (with a few exceptions) +

    Each flag (with a few exceptions) has a long and short form. While it is most common to use the short form, it is recommended that you familiarize yourself with the long form, so that you remember what each flag is supposed to do.

    @@ -89,15 +89,22 @@ 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:

    -

    -RewriteRule ^(/.*)$ /index.php?show=$1 -

    +
    RewriteRule ^search/(.*)$ /search.php?term=$1
    + + +

    Given a search term of 'x & 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 +flag, this rewrite rule will map to 'search.php?term=x & y/z', which +isn't a valid URL, and so would be encoded as +search.php?term=x%20&y%2Fz=, which is not what was intended.

    -

    This will map /C++ to -/index.php?show=/C++. But it will also map -/C%2b%2b to /index.php?show=/C++, because -the %2b has been unescaped. With the B flag, it will -instead map to /index.php?show=/C%2b%2b.

    +

    With the B flag set on this same rule, the parameters are re-encoded +before being passed on to the output URL, resulting in a correct mapping to +/search.php?term=x%20%26%20y%2Fz.

    + +

    Note that you may also need to set AllowEncodedSlashes to On to get this +particular example to work, as httpd does not allow encoded slashes in URLs, and +returns a 404 if it sees one.

    This escaping is particularly necessary in a proxy situation, when the backend may break if presented with an unescaped URL.

    @@ -141,7 +148,6 @@ security model.

    You may optionally also set the following values:

    -
    Lifetime
    The time for which the cookie will persist, in minutes.
    A value of 0 indicates that the cookie will persist only for the @@ -343,13 +349,13 @@ C. Use this flag to indicate that the current rule should be applied immediately without considering further rules.

    If you are using RewriteRule in either -.htaccess files or in +.htaccess files or in <Directory> sections, it is important to have some understanding of how the rules are processed. The simplified form of this is that once the rules have been processed, the rewritten request is handed back to the URL parsing engine to do what it may with it. It is possible that as the rewritten -request is handled, the .htaccess file or +request is handled, the .htaccess file or <Directory> section may be encountered again, and thus the ruleset may be run again from the start. Most commonly this will happen if one of the rules causes a @@ -363,7 +369,7 @@ rules, as shown below.

    The example given here will rewrite any request to index.php, giving the original request as a query string -argument to index.php, however, the RewriteCond ensures that if the request +argument to index.php, however, the RewriteCond ensures that if the request is already for index.php, the RewriteRule will be skipped.

    @@ -443,7 +449,7 @@ On subrequests, it is not always useful, and can even cause errors, if the complete set of rules are applied. Use this flag to exclude problematic rules.

    -

    To decide whether or not to use this rule: if you prefix URLs with +

    To decide whether or not to use this rule: if you prefix URLs with CGI-scripts, to force them to be processed by the CGI-script, it's likely that you will run into problems (or significant overhead) on sub-requests. In these cases, use this flag.

    @@ -498,15 +504,15 @@ The target (or substitution string) in a RewriteRule is assumed to be a file path, by default. The use of the [PT] flag causes it to be treated as a URI instead. That is to say, the use of the [PT] flag causes the result of the RewriteRule to be passed back through -URL mapping, so that location-based mappings, such as Alias, Redirect, or ScriptAlias, for example, might have a +URL mapping, so that location-based mappings, such as Alias, Redirect, or ScriptAlias, for example, might have a chance to take effect.

    -If, for example, you have an +If, for example, you have an Alias for /icons, and have a RewriteRule pointing there, you should -use the [PT] flag to ensure that the +use the [PT] flag to ensure that the Alias is evaluated.

    @@ -564,8 +570,8 @@ will be used to generate the URL sent with the redirect.

    -Any valid HTTP response status code may be specified, -using the syntax [R=305], with a 302 status code being used by +Any valid HTTP response status code may be specified, +using the syntax [R=305], with a 302 status code being used by default if none is specified. The status code specified need not necessarily be a redirect (3xx) status code. However, if a status code is outside the redirect range (300-399) then the @@ -573,7 +579,7 @@ substitution string is dropped entirely, and rewriting is stopped as if the L were used.

    In addition to response status codes, you may also specify redirect -status using their symbolic names: temp (default), +status using their symbolic names: temp (default), permanent, or seeother.

    @@ -587,21 +593,23 @@ URI in request' warnings.

    top

    S|skip

    -

    The [S] flag is used to skip rules that you don't want to run. This -can be thought of as a goto statement in your rewrite -ruleset. In the following example, we only want to run the RewriteRule if the requested URI -doesn't correspond with an actual file.

    - -

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

    The [S] flag is used to skip rules that you don't want to run. The +syntax of the skip flag is [S=N], where N signifies +the number of rules to skip. This can be thought of as a goto +statement in your rewrite ruleset. In the following example, we only want +to run the RewriteRule if the +requested URI doesn't correspond with an actual file.

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

    + +

    This technique is useful because a RewriteCond only applies to the RewriteRule immediately @@ -620,14 +628,14 @@ RewriteRule .? - [S=3]

    # IF the file exists, then: - RewriteRule (.*\.gif) images.php?$1
    - RewriteRule (.*\.html) docs.php?$1
    - # Skip past the "else" stanza.
    - RewriteRule .? - [S=1]
    + RewriteRule (.*\.gif) images.php?$1
    + RewriteRule (.*\.html) docs.php?$1
    + # Skip past the "else" stanza.
    + RewriteRule .? - [S=1]
    # ELSE... - RewriteRule (.*) 404.php?file=$1
    + RewriteRule (.*) 404.php?file=$1
    # END

    @@ -662,10 +670,10 @@ invariably be a less efficient solution than the alternatives.

    If used in per-directory context, use only - (dash) -as the substitution for the entire round of mod_rewrite processing, -otherwise the MIME-type set with this flag is lost due to an internal +as the substitution for the entire round of mod_rewrite processing, +otherwise the MIME-type set with this flag is lost due to an internal re-processing (including subsequent rounds of mod_rewrite processing). -The L flag can be useful in this context to end the +The L flag can be useful in this context to end the current round of mod_rewrite processing.

    diff --git a/docs/manual/rewrite/flags.xml.fr b/docs/manual/rewrite/flags.xml.fr index 79d58b2d82b..0ad2eedc016 100644 --- a/docs/manual/rewrite/flags.xml.fr +++ b/docs/manual/rewrite/flags.xml.fr @@ -1,7 +1,7 @@ - + diff --git a/docs/manual/rewrite/intro.html.en b/docs/manual/rewrite/intro.html.en index 7bb3fce394a..5edc9eb3366 100644 --- a/docs/manual/rewrite/intro.html.en +++ b/docs/manual/rewrite/intro.html.en @@ -39,7 +39,7 @@ but this doc should help the beginner get their feet wet.
  • Rewrite Conditions
  • Rewrite maps
  • .htaccess files
  • -

    See also

    +

    See also

    top

    Introduction

    @@ -103,7 +103,7 @@ well as write your own.

    characterc.t will match cat, cot, cut, etc. +Repeats the previous match one or more -timesa+ matches a, aa, +timesa+ matches a, aa, aaa, etc *Repeats the previous match zero or more times.a* matches all the same things @@ -118,7 +118,7 @@ of the string^a matches a string that begins with the string.a$ matches a string that ends with a. ( )Groups several characters into a single -unit, and captures a match for use in a backreference.(ab)+ +unit, and captures a match for use in a backreference.(ab)+ matches ababab - that is, the + applies to the group. For more on backreferences see below. [ ]A character class - matches one of the @@ -141,14 +141,19 @@ the expression.

    CondPattern, back-references are internally created which can be used with the strings $N and %N (see below). These are available for creating - the strings Substitution and TestString. - Figure 1 shows to which locations the back-references are - transferred for expansion as well as illustrating the flow of the - RewriteRule, RewriteCond matching.

    + the strings Substitution and TestString as + outlined in the following chapters. Figure 1 shows to which + locations the back-references are transferred for expansion as + well as illustrating the flow of the RewriteRule, RewriteCond + matching. In the next chapters, we will be exploring how to use + these back-references, so do not fret if it seems a bit alien + to you at first. +

    - Flow of RewriteRule and RewriteCond matching
    - Figure 1: The back-reference flow through a rule. + Flow of RewriteRule and RewriteCond matching
    + Figure 1: The back-reference flow through a rule.
    + In this example, a request for /test/1234 would be transformed into /admin.foo?page=test&id=1234&host=admin.example.com.

    @@ -163,10 +168,15 @@ of three arguments separated by spaces. The arguments are

  • [flags]: options affecting the rewritten request.
  • -

    The Pattern is always a regular -expression matched against the URL-Path of the incoming request -(the part after the hostname but before any question mark indicating -the beginning of a query string).

    +

    The Pattern is a regular expression. +It is initially (for the first rewrite rule or until a substitution occurs) +matched against the URL-path of the incoming request (the part after the +hostname but before any question mark indicating the beginning of a query +string) or, in per-directory context, against the request's path relative +to the directory for which the rule is defined. Once a substitution has +occured, the rules that follow are matched against the substituted +value. +

    Syntax of the RewriteRule directive
    diff --git a/docs/manual/rewrite/intro.html.fr b/docs/manual/rewrite/intro.html.fr index 2c145c4aa6a..b8aaaf7d178 100644 --- a/docs/manual/rewrite/intro.html.fr +++ b/docs/manual/rewrite/intro.html.fr @@ -24,6 +24,8 @@

    Langues Disponibles:  en  |  fr 

    +
    Cette traduction peut être périmée. Vérifiez la version + anglaise pour les changements récents.

    Ce document est un complément à la documentation de référence du module mod_rewrite. Il décrit les concepts de base dont la diff --git a/docs/manual/rewrite/intro.xml.fr b/docs/manual/rewrite/intro.xml.fr index 36d5aaf22cc..eac3eaf98c5 100644 --- a/docs/manual/rewrite/intro.xml.fr +++ b/docs/manual/rewrite/intro.xml.fr @@ -1,7 +1,7 @@ - + diff --git a/docs/manual/rewrite/intro.xml.meta b/docs/manual/rewrite/intro.xml.meta index 5aaac0fc867..ce245b2841c 100644 --- a/docs/manual/rewrite/intro.xml.meta +++ b/docs/manual/rewrite/intro.xml.meta @@ -8,6 +8,6 @@ en - fr + fr