Document Modelling

Redirect Documents

Redirects help you organise your delivery.

Redirects

You can define redirections for the webapp, so that requests to specific paths are redirected to other locations. These locations include documents, URLs relative to your website, and external URLs. There are four different types of redirects that can be configured via redirect documents in the administration view, videlicet REDIRECT, METAREDIRECT, SSI and MAPPING.

Prerequisites

In order for the redirects to work, a template for the nodetype sophora-nt:shortcut must be configured in the delivery webapp. See the Delivery Documentation for details. Additionally, all redirect types you want to use must be added to the Select Value document for redirect types, with its values out of the four possibilities (usually redirecttypes100).

Redirect Types

  • METAREDIRECT: this redirect is embedded in the header of the HTML ("meta refresh") and redirects to a specific document relative path or an external URL.
  • SSI (Preserve Path): this redirect maintains the same URL while loading content from a specific document or relative path.
  • MAPPING: this redirect maps the request to a different relative path. This way, requests for content in a non existent structure node or path are redirected to an existing structure node, where the content can be found. This type is comparable to structure node aliases, with the exception that mapping redirects are not considered when generating document URLs, whereas structurenode aliases are considered.
  • REDIRECT: this redirect is sent to the client via the HTTP response and redirects to a specific document, relative path or external URL. It is not recommended to use this type of redirect, unless there is a good reason to do so. METAREDIRECT should be used instead, since it is easier to implement and redirects get cached.

Redirect Document

You can create and edit redirect documents in the administration view at System >> Redirect Documents. Only published changes will take effect.

Redirections of the type Redirect require an arbitrary URL as argument in the column Forward to URL. Redirections of type Preserve Path only accept another Sophora document. Therefore, you can drag and drop the target document into the column Forward to Sophora document.

Within the column Request path, you can specify multiple values to be redirected to either the given URL or the Sophora document (dependent on the redirection type). By that, you can define different paths to be redirected to one target. In addition, you can configure a regular expression like /demosite/inland.*.

You can set different channel names for the same redirection path in order to indicate different targets. If no channel name is set, the default channel will be used.
Remember that it is necessary to define a template set in the template.xml for the specified channel and the shortcut.jsp. Please refer to the Sophora Delivery documentation for this concern.

Within the column Comment, you can leave a comment on a redirect for informational purposes.

+++
+++ (Image: subshell/CC BY)

If there are multiple redirections defined for an individual path, they are prioritised following the given order in the table. However, redirections that have been defined via such redirect documents from within the deskclient, are preferred to those defined in the templates.xml in the delivery.

Redirect Types in the Webapp Framework

In the new Webapp Framework, the redirect types have changed. If you are already using the Webapp Framework, then the redirect types are as follows:

  • FORWARD (Preserve Path): This redirect maintains the same URL while loading content from a specific document or relative path. An internal forward is performed, so you cannot redirect to an external URL with this redirect type.
  • TEMPORARY_REDIRECT: This redirect sends a HTTP response to the client with Location Header-Field set to the configured document, relative path or absolute (external) URL. The HTTP status code will be 302.
  • PERMANENT_REDIRECT: This redirect sends a HTTP response to the client with Location Header-Field set to the configured document, relative path or absolute (external) URL. The HTTP status code will be 301.
  • Custom types: The Webapp Framework allows defining of custom redirect types. The Webapp should provide an implementation of the interface com.subshell.sophora.webapp.routing.redirect.ICustomRedirectBuilder to perform browser or internal redirects for custom redirect types.

Last modified on 10/16/20

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon