Page History
...
The mappings are delegated to a separate module ( virtual-uri
) through the the info.magnolia.virtualuri.VirtualUriFilter
class class and are stored in their own registry (VirtualUriRegistry
), which allows to reference each mapping also in YAML definition files. All virtual URI mappings can be located via the Definitions app no matter whether they come from JCR or a YAML file:
...
- Web pages have moved due to site re-organization. Users still have old URLs in their bookmarks and in search engine indexes. Without redirection traffic would be lost.
- Registering alternative domain extensions like
example.net
andexample.org
and redirecting them to your primary siteexample.com
. You can map multiple domain names to a site in your Magnolia site definition. This can be a major time-saver for a CMS team since there is no need to configure a Web server. Note that you need to register the domains with a registrar first and make sure that DNS entries for the domains point to the server hosting your Magnolia instance.
As an example of mapping, see also Turning a template-based JSON provider into a RESTful API with virtualURIMapping where we define a custom virtual mapping to rewrite a path like /getjson/tours/magnolia-travels/Kyoto
into into /getjson?workspace=tours&path=/magnolia-travels/Kyoto
.
...
Info | ||||||
---|---|---|---|---|---|---|
Please note that the YAML-based configuration must be stored under the
|
...
Example: A mapping named enterprise-edition
forwards users from example.com/ee
to example.com/enterprise-edition
. The DefaultVirtualUriMapping
class (for description see the Mapping classes section below) maps one URI to another. This ensures that external links that point to example.com/ee
still work when the target page is renamed.
...
info.magnolia.virtualuri.mapping.*
maps a virtual URI to a content path. This is the simplest and most common type.Javadoc resource link className info.magnolia.virtualuri.mapping.DefaultVirtualUriMapping renderType asynchronous
If the URI starts with a dot (.
), it is not taken as a wildcard anymore but the dot in fact is interpreted as dot. If you need a wildcard, use?
instead.
allows you to specify a regular expression pattern that matches a sequence of characters. A regexp pattern can match a variety of URIs, which saves time and effort as you would otherwise have to create default mappings for each case.Javadoc resource link className info.magnolia.virtualuri.mapping.RegexpVirtualUriMapping renderType asynchronous toUri
can contain back references to the regexp matches.
is an extension ofJavadoc resource link className info.magnolia.virtualuri.mapping.RotatingVirtualUriMapping renderType asynchronous RegexpVirtualUriMapping
that allows rotation between different destination URIs. In order to rotate,toUri
must contain an asterisk character*
that will be replaced by a random integer betweenstart
(default is 1) andend
minus one (default is3
). An additional propertypadding
specifies the desired width of the string. Zeroes are added to the left of the integer to make all strings equally wide. Default width is2
.
forwards the request to a different URI depending on the requested host name.Javadoc resource link className info.magnolia.virtualuri.mapping.HostBasedVirtualUriMapping renderType asynchronous
combines the host-based and regex mappings, i.e. forwards the request to a different URI depending on the requested host name and allows you to specify a regular expression pattern that matches a sequence of characters.Javadoc resource link className info.magnolia.virtualuri.mapping.HostBasedRegexpVirtualUriMapping renderType asynchronous
info.magnolia.multisite.mapping.*
is a special class which specifies the root of a site if site matching returnsJavadoc resource link className info.magnolia.multisite.mapping.MultiSiteRootVirtualUriMapping renderType asynchronous null
.
adds a site condition to the mapURI check. A A mapping will only match the request if both the specified regular expression and the specified site match.Javadoc resource link className info.magnolia.multisite.mapping.MultiSiteRegexpVirtualUriMapping renderType asynchronous
...
The patterns for regular expressions in the regex-based classes are defined in java.util.regex.Pattern .
Action prefixes
You can use these action prefixes:
...
It is also possible to leave the action prefix out. A virtual URI mapping that does not have a prefix does not re-process the request. It just changes the current URI in the
Javadoc resource link | ||||
---|---|---|---|---|
|
Examples
Default
Forward from /winter2016
to /marketing/campaigns/winter2016
.
Advanced Tables - Table Plus | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||
|
...
A request URI such as forward:/banner/image_*.jpg
will randomly forward the request to /banner/image_01.jpg
, /banner/image_02.jpg
or /banner/image_03.jpg
. A use case for this class is rotating images such as banner ads. The mapping displays a random ad on each page visit.
...
Forward the visitor to a German language version of the home page when the site is requested with the .de
country domain. Similarly, forward to a French version when the site is requested with the .fr
country domain. The matching pattern is in the host
property. The toUri
value under the parent node works as a fallback option. If no hostname match is found, such as when the site is requested with acme.com
, forward to an English version.
...