From c314a8ef9f39bc11535ea75e3f9a8ba2287fd051 Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Sat, 6 Dec 2014 14:14:39 +0000 Subject: [PATCH] xforms git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643533 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/rewrite/remapping.html.en | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/docs/manual/rewrite/remapping.html.en b/docs/manual/rewrite/remapping.html.en index b8c9e20d17..6714522147 100644 --- a/docs/manual/rewrite/remapping.html.en +++ b/docs/manual/rewrite/remapping.html.en @@ -48,6 +48,7 @@ configuration.
  • Canonical URLs
  • Moved DocumentRoot
  • Fallback Resource
  • +
  • Rewrite query string
  • See also

    top
    @@ -565,6 +566,63 @@ file, as well as in a <Directory> block.

    +
    top
    +
    +

    Rewrite query string

    + + +
    +
    Description:
    +
    You want to capture a particular value from a query string +and either replace it or incorporate it into another component +of the URL.
    + +
    Solutions:
    +
    +

    Many of the solutions in this section will all use the same condition, +which leaves the matched value in the %2 backreference. %1 is the beginining +of the query string (up to the key of intererest), and %3 is the remainder. This +condition is a bit complex for flexibility and to avoid double '&&' in the +substitutions.

    +
      +
    • This solution removes the matching key and value: + +
      # Remove mykey=???
      +RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
      +RewriteRule (.*) $1?%1%3
      + +
    • + +
    • This solution uses the captured value in the URL subsitution, + discarding the rest of the original query by appending a '?': + +
      # Copy from query string to PATH_INFO
      +RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
      +RewriteRule (.*) $1/products/%2/? [PT]
      + +
    • + +
    • This solution checks the captured value in a subsequent condition: + +
      # Capture the value of mykey in the query string
      +RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
      +RewriteCond %2 !=not-so-secret-value 
      +RewriteRule (.*) - [F]
      + +
    • + +
    • This solution shows the reverse of the previous ones, copying + path components (perhaps PATH_INFO) from the URL into the query string. +
      # The desired URL might be /products/kitchen-sink, and the script expects 
      +# /path?products=kitchen-sink.
      +RewriteRule ^/?path/([^/]+)/([^/]+) /path?$1=$2 [PT]
      + +
    • +
    + +
    + +

    Available Languages:  en 

    -- 2.40.0