From 2929211635455d657bc311ba00030b960ff381c4 Mon Sep 17 00:00:00 2001 From: Rich Bowen Date: Thu, 5 Nov 2009 15:43:23 +0000 Subject: [PATCH] Moves the "canonial URL" example to remapping git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@833061 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/rewrite/remapping.html.en | 46 ++++++++++++++++++++++- docs/manual/rewrite/remapping.xml | 45 ++++++++++++++++++++++ docs/manual/rewrite/rewrite_guide.html.en | 38 +------------------ docs/manual/rewrite/rewrite_guide.xml | 35 ----------------- 4 files changed, 91 insertions(+), 73 deletions(-) diff --git a/docs/manual/rewrite/remapping.html.en b/docs/manual/rewrite/remapping.html.en index df8eb72e94..bbb78fdb41 100644 --- a/docs/manual/rewrite/remapping.html.en +++ b/docs/manual/rewrite/remapping.html.en @@ -43,6 +43,7 @@ configuration.
  • Search for pages in more than one directory
  • Redirecting to Geographically Distributed Servers
  • Browser Dependent Content
  • +
  • Canonical URLs
  • See also

    top
    @@ -437,7 +438,50 @@ RewriteRule ^foo\.html$ foo.32.html [L -
    +
    top
    +
    +

    Canonical URLs

    + + + +
    +
    Description:
    + +
    +

    On some webservers there is more than one URL for a + resource. Usually there are canonical URLs (which are be + actually used and distributed) and those which are just + shortcuts, internal ones, and so on. Independent of which URL the + user supplied with the request, they should finally see the + canonical one in their browser address bar.

    +
    + +
    Solution:
    + +
    +

    We do an external HTTP redirect for all non-canonical + URLs to fix them in the location view of the Browser and + for all subsequent requests. In the example ruleset below + we replace /puppies and /canines + by the canonical /dogs.

    + +
    +RewriteRule   ^/(puppies|canines)/(.*)    /dogs/$2  [R]
    +
    +
    + +
    Discussion:
    +
    + This should really be accomplished with Redirect or RedirectMatch + directives: + +
    +     RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2
    +     
    +
    +
    + +

    Available Languages:  en 

    -
    • Canonical URLs
    • -
    • Moved DocumentRoot
    • +
      top
      -

      Canonical URLs

      - - - -
      -
      Description:
      - -
      -

      On some webservers there are more than one URL for a - resource. Usually there are canonical URLs (which should be - actually used and distributed) and those which are just - shortcuts, internal ones, etc. Independent of which URL the - user supplied with the request he should finally see the - canonical one only.

      -
      - -
      Solution:
      - -
      -

      We do an external HTTP redirect for all non-canonical - URLs to fix them in the location view of the Browser and - for all subsequent requests. In the example ruleset below - we replace /~user by the canonical - /u/user and fix a missing trailing slash for - /u/user.

      - -
      -RewriteRule   ^/~([^/]+)/?(.*)    /u/$1/$2  [R]
      -RewriteRule   ^/u/([^/]+)$  /$1/$2/   [R]
      -
      -
      -
      - -
      top
      -

      Moved DocumentRoot

      diff --git a/docs/manual/rewrite/rewrite_guide.xml b/docs/manual/rewrite/rewrite_guide.xml index df2e137ece..f6b3578c22 100644 --- a/docs/manual/rewrite/rewrite_guide.xml +++ b/docs/manual/rewrite/rewrite_guide.xml @@ -54,41 +54,6 @@ useful examples Technical details -
      - -Canonical URLs - -
      -
      Description:
      - -
      -

      On some webservers there are more than one URL for a - resource. Usually there are canonical URLs (which should be - actually used and distributed) and those which are just - shortcuts, internal ones, etc. Independent of which URL the - user supplied with the request he should finally see the - canonical one only.

      -
      - -
      Solution:
      - -
      -

      We do an external HTTP redirect for all non-canonical - URLs to fix them in the location view of the Browser and - for all subsequent requests. In the example ruleset below - we replace /~user by the canonical - /u/user and fix a missing trailing slash for - /u/user.

      - -
      -RewriteRule   ^/~([^/]+)/?(.*)    /u/$1/$2  [R]
      -RewriteRule   ^/u/([^/]+)$  /$1/$2/   [R]
      -
      -
      -
      - -
      -
      Moved <code>DocumentRoot</code> -- 2.40.0