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 different predefined types of redirects that can be configured via redirect documents in the administration view: FORWARD
, PERMANENT_REDIRECT
and TEMPORARY_REDIRECT
. Alternatively, you can always define own redirect types with custom HTTP status codes.
Prerequisites
All redirect types you want to use must be added to the Select Value document for redirect types (usually redirecttypes100
), with its values out of the three predefined redirect types or any 3xx HTTP status codes (301, 302, ...).
Redirect Types
- 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 be302
. - 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 be301
. - 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.
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 type FORWARD only accept another Sophora document or any internal path (paths to static resources in the WebApp are also possible, see docs for WebApp Framework). 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 you might write your own RedirectHandler
for special processing of other channels than default.
Within the column Comment, you can leave a comment on a redirect for informational purposes.
![+++ +++](/docs/images/image-documentmodelling190~largeDocs.1708594022638.jpg)
If there are multiple redirections defined for an individual path, they are prioritised following the given order in the table.