Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
HTML Wrap | ||||
---|---|---|---|---|
| ||||
Related topics: |
Virtual URI mapping is a way to redirect an incoming request to the actual location of the content. Typically the virtual address does not match the site hierarchy exactly.
...
The URIs can be either absolute or relative within the web application in which case the context path is added automatically. For example:
Info |
---|
It's important to keep in mind the placement of the virtualURIFilter in the chain. The filter acts on the current URI at the time of execution. Any selectors removed from the current URI before the filter executes cannot be configured in |
fromUri: /winter2016
toUri: forward:/marketing/campaigns/winter2016
fromUri: /winter2016
toUri: forward:/marketing/campaigns/winter2016
AbsolutefromUri: /winter2016
toUri: forward:https://www.example.com/marketing/campaigns/winter2016.html
Before Magnolia 5.5.6, virtual URI mapping was part of the core. With the release of 5.5.6 the mapping is delegated to a separate module ( virtual-uri
) through the info.magnolia.virtualuri.VirtualUriFilter
class. Moreover, the mappings themselves The mappings are delegated to a separate module ( virtual-uri
) through the info.magnolia.virtualuri.VirtualUriFilter
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:
You can also check the mappings in the About app's Virtual URI Mappings tab, or by searching the config
space with the Alternatively, search the config
space with the JCR browser app:
...
Advanced Tables - Table Plus | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||
|
( Magnolia 5.5.6+) You can configure virtual URI mappings in a YAML definition file inside a light module folder:
...
class | required Class that performs the mapping. See the section Mapping classes below. |
fromUri | required Pattern to match in the requested URI. |
toUri | required Concrete URI where the request is mapped to. |
site | required (for the Specifies the site that should be used for the mapping. |
Info |
---|
Please be aware that with Magnolia 5.5.6+, the case of the |
( Magnolia 5.5.6+) For easier orientation, if you have to configure a lot of mappings, you can store them in folder-like structures rather than in one long flat list of mappings:
For easier orientation, if you have to configure a lot of mappings, you can store them in folder-like structures rather than in one long flat list of mappings:
Advanced Tables - Table Plus | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Advanced Tables - Table Plus | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
...
info.magnolia.virtualuri.mapping.*
Javadoc resource link | ||||
---|---|---|---|---|
|
.
), it is not taken as a wildcard anymore but the dot in fact is interpreted as dot. If you need a wildcard, use ?
instead.Javadoc resource link | ||||
---|---|---|---|---|
|
toUri
can contain back references to the regexp matches.Javadoc resource link | ||||
---|---|---|---|---|
|
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 between start
(default is 1) and end
minus one (default is 3
). An additional property padding
specifies the desired width of the string. Zeroes are added to the left of the integer to make all strings equally wide. Default width is 2
.Javadoc resource link | ||||
---|---|---|---|---|
|
Javadoc resource link | ||||
---|---|---|---|---|
|
info.magnolia.module.googlesitemap.config.mapping.*
Javadoc resource link | ||||
---|---|---|---|---|
|
googleSitemaps
workspace and prepends the prefix.info.magnolia.multisite.mapping.*
Javadoc resource link | ||||
---|---|---|---|---|
|
null
. Javadoc resource link | ||||
---|---|---|---|---|
|
You You can also write your own implementation.
The patterns for regular expressions in the regex-based classes are defined in java.util.regex.Pattern .
Anchor | ||||
---|---|---|---|---|
|
With the introduction of the virtual-uri
module in The following classes have been deprecated with the release of Magnolia 5.5.6, the following classes have been deprecated:
info.magnolia.cmsmodule.beansgooglesitemap.config.*
Javadoc resource link | ||||||
---|---|---|---|---|---|---|
|
info.magnolia.multisite.*
Javadoc resource link | rangeHigherVersion | 5.5.6|||
---|---|---|---|---|
|
Javadoc resource link | rangeHigherVersion | 5.5.6|||
---|---|---|---|---|
|
Javadoc resource link | ||||||
---|---|---|---|---|---|---|
|
Javadoc resource link | ||||||
---|---|---|---|---|---|---|
|
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 | ||||
---|---|---|---|---|
|
Forward from /winter2016
to /marketing/campaigns/winter2016
.
Advanced Tables - Table Plus | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||
|
...
|
Info | ||
---|---|---|
| ||
Always test your regex-based virtual URI configurations thoroughly before applying them to a live environment. The configurations that seem correct on the surface can yield unwanted results. For example, using boundary matchers (the hat |
Take requested page name and pass it as a productId
request parameter to a product detail page.
Advanced Tables - Table Plus | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||
|
The pattern [0-9a-9AzA-Z-]
in fromUri
means "any single character in the range of 0-9 or a-z or A-Z or the character -
Z literally". The plus character makes this a greedy pattern that matches one or more of the preceding token, and will match as many characters as possible before satisfying the next token. By enclosing the pattern in parentheses we create a capturing group ([0-9a-9AzA-Z-]+])
which can be referenced in the toUri
using $1
.
...
Advanced Tables - Table Plus | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||
|
Anchor | ||||
---|---|---|---|---|
|
The mapping redirects the requests for sitemaps to the /sitemaps
node. The configuration is taken from the google-sitemap
module in the default installation of Magnolia:
Advanced Tables - Table Plus | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
Node name | Value |
|
|
Mgnl p |
---|
Node name | Value | |
---|---|---|
| ||
| ||
| info.magnolia.module.googlesitemap.config.mapping.SiteMapVirtualUriMapping | |
| redirect:/sitemaps |
Properties:
|
|
...
googleSitemaps workspace and prepends the prefix. | ||||
| Prefix prepended by the class. |
...
Mgnl p |
---|
...
Module | Edition | Mapping class | From (Site) | To | activation | CE, EE | |
---|---|---|---|---|---|---|---|
/ActivationHandler | forward:/.magnolia/activation |
(Author Instance) | EE |
| / | redirect:/.magnolia/admincentral | |
(Author Instance) | CE |
| / | redirect:/.magnolia/admincentral | |||
(Public Instance) | EE |
| / | redirect:/travel.html | |||
(Public Instance) | CE |
| / | redirect:/travel.html | |||
google-sitemap | CE, EE |
| redirect:/sitemaps | ||||
rssaggregator | CE, EE |
| /rssFeeds/(.*) | redirect:/rss/?feedPath=/$1 | |||
rssaggregator | CE, EE |
| /planetFeeds/(.*) | redirect:/rss/?feedPath=/$1&generatorName=planet | |||
rssaggregator | CE, EE |
|
| redirect:/rss/?generatorName=category&categories=$1&siteRoot=/$2 | |||
tours | CE |
|
| forward:/travel/tour?tour=$1 | |||
tours | EE |
|
( | forward:/tour?tour=$1 | |||
tours | EE |
|
( |
|