Return-Path: Delivered-To: apmail-cocoon-docs-archive@www.apache.org Received: (qmail 13990 invoked from network); 7 Jun 2007 16:19:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Jun 2007 16:19:17 -0000 Received: (qmail 24253 invoked by uid 500); 7 Jun 2007 16:19:21 -0000 Delivered-To: apmail-cocoon-docs-archive@cocoon.apache.org Received: (qmail 24232 invoked by uid 500); 7 Jun 2007 16:19:20 -0000 Mailing-List: contact docs-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: docs@cocoon.apache.org List-Id: Delivered-To: mailing list docs@cocoon.apache.org Received: (qmail 24219 invoked by uid 99); 7 Jun 2007 16:19:20 -0000 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.67] (HELO cocoon.zones.apache.org) (140.211.11.67) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2007 09:19:20 -0700 Message-ID: <29899357.1181233136793.JavaMail.daisy@cocoon.zones.apache.org> Date: Thu, 7 Jun 2007 16:18:56 +0000 (GMT+00:00) From: daisy@cocoon.zones.apache.org To: docs@cocoon.apache.org Subject: [DAISY] Created: Redirects Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org A new document has been created. http://cocoon.zones.apache.org/daisy/documentation/1378.html Document ID: 1378 Branch: main Language: default Name: Redirects Document Type: Cocoon Document Created: 6/7/07 4:18:48 PM Creator (owner): Reinhard P=C3=B6tz State: publish Parts =3D=3D=3D=3D=3D Content ------- Mime type: text/xml Size: 4267 bytes Content:

Introduction

A Redirector allows the sitemap to pass a request for one URI on to anot= her, whether that other URI is handled by Cocoon or not.

To redirect from page1.html to page2.html, you can use= the following:

  <map:match pattern=3D"page1.html">
    <map:redirect-to uri=3D"page2.html"/>
  </map:match>

        

HTTP redirects and how they work

If the URI specified does not use the Cocoon: protocol, then an HTTP red= irect will occur. The new URI is sent back to the client, which will then request= the page from this new location.

Therefore, directory handling in redirect URIs works differently from ot= her sitemap components.

If the new URI is relative, then it will be relative to the directory of= the page that called it, not relative to the URI of the sitemap containing it. = Thus, the following is incorrect:

  <map:match pattern=3D"folder/page1.html">
    <map:redirect-to uri=3D"folder/page2.html"/>
  </map:match>

This will in fact redirect the user to folder/folder/page2.html, which i= s probably not intended. The correct version is:

  <map:match pattern=3D"folder/page1.html">
    <map:redirect-to uri=3D"page2.html"/>
  </map:match>
   =20

Internal Redirects Using the Cocoon Protocol

A redirection URI can make use of the cocoon: protocol to retur= n content from another Cocoon pipeline. In this case, the redirection happens internally. The content from the redirected URI is returned to the client a= s if it came from the original URI.

Directory handling is the same here as for other sitemap components. So = that:

  <map:match pattern=3D"folder/page1.html">
    <map:redirect-to uri=3D"cocoon:/folder/page2.html"/>
  </map:match>

will return the content of page2.html to the client in response= to the request for page1.html.

Note: when the cocoon: protocol is used, an HTTP redirect is no= t used.

Session Management with Redirects

By setting the session attribute to yes, the current session will be maintained during the redirect.

Temporary and Permanent Redirects

By default, an HTTP redirect sends a code of SC_MOVED_TEMPORARILY, (302). This instructs the user agent to use the new URI, but not t= o cache the resulting page, as it may well soon revert back to the old URI.

This can be a problem for pages that have been moved permanently, as the= new page will never be cached, placing additional load on both the browser and = on the server.

This can be avoided using a permanent redirect, using a code of SC_MOVED_PERMANENTLY (301). A permanent redirect can be specified as:

  <map:match pattern=3D"page1.html">
    <map:redirect-to uri=3D"page2.html" permanent=3D"yes"/>
  </map:match>

        

This results in the user agent caching the redirected page, and thus sav= es resources both on the server and for the client's browser.

Redirects in Pipelines

A redirect must stand alone in a pipeline - it cannot occur after a generator. If a redirect needs to be generated conditionally by a pipeline,= then a <meta> tag redirect should be added into the <head> of the HTML page. The syntax for this is:

 =20
<html>
  <head>
    <meta http-equiv=3D"refresh" content=3D"0;URL=3Dpage2.html"/>
    ...
  </head>
  ...
</html>

        

Global Redirects

When an aggregator accesses a source that includes a redirection, it wil= l aggregate the document specified by the redirection URI.

Alternatively, if a redirection that has the global attribute i= s set (to yes or true) occurs within an aggregation, the aggreg= ation is cancelled and the redirect is sent back to the client.

Redirecting to Resources

Specifiying a resource attribute allows the redirection to a si= temap resource. This usage has been deprecated. map:call should be used instead.

Collections =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The document belongs to the following collections: cdocs-core