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 . For example, langauge selectors would be removed from the current URI before the filter executes. |
- Relative
fromUri: /winter2016
toUri: forward:/marketing/
Relative
fromUri: /winter2016
toUri: forward:/marketing/campaigns/winter2016
- Absolute
fromUri: /winter2016
toUri: forward:https://www.example.com/marketing/campaigns/winter2016.html
...
info.magnolia.virtualuri.mapping.*
Javadoc resource link |
---|
className | info.magnolia.virtualuri.mapping.DefaultVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
maps a virtual URI to a content path. This is the simplest and most common type.
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. Javadoc resource link |
---|
className | info.magnolia.virtualuri.mapping.RegexpVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
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. toUri
can contain back references to the regexp matches. Javadoc resource link |
---|
className | info.magnolia.virtualuri.mapping.RotatingVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
is an extension of 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 |
---|
className | info.magnolia.virtualuri.mapping.HostBasedVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
forwards the request to a different URI depending on the requested host name. Javadoc resource link |
---|
className | info.magnolia.virtualuri.mapping.HostBasedRegexpVirtualUriMapping |
---|
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.
info.magnolia.module.googlesitemap.config.mapping.*
Javadoc resource link |
---|
className | info.magnolia.module.googlesitemap.config.mapping.SiteMapVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
compares source URI to names of sitemaps available in the googleSitemaps
workspace and prepends the prefix.
info.magnolia.multisite.mapping.*
Javadoc resource link |
---|
className | info.magnolia.multisite.mapping.MultiSiteRootVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
is a special class which specifies the root of a site if site matching returns null
. Javadoc resource link |
---|
className | info.magnolia.multisite.mapping.MultiSiteRegexpVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
adds a site condition to the mapURI check. A mapping will only match the request if both the specified regular expression and the specified site match.
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 |
---|
| deprecated-classes |
---|
| deprecated-classes |
---|
|
...
Advanced Tables - Table Plus |
---|
heading | 0 |
---|
enableHeadingAttributes | false |
---|
enableSorting | false |
---|
class | m5-configuration-tree |
---|
enableHighlighting | false |
---|
|
Node name | Value |
---|
|
| |
| | info.magnolia.virtualuri.mapping.DefaultVirtualUriMapping | | /winter2016 | | forward:/marketing/campaigns/winter2016 | |
Regular expression
| forward:/marketing/campaigns/winter2016 |
|
Regular expression
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 ^ , the dollar $ , and others) in fromUri and toUri may improve your matches otherwise a simple value such as /foobar.html will be matched not only in /foobar.html but also in /something/foobar.html . |
Take requested page name and pass it as a productId
request parameter to a product detail page.
Advanced Tables - Table Plus |
---|
heading | 0 |
---|
enableHeadingAttributes | false |
---|
enableSorting | false |
---|
class | m5-configuration-tree |
---|
enableHighlighting | false |
---|
|
Node name | Value |
---|
|
| |
| | info.magnolia.virtualuri.mapping.RegexpVirtualUriMapping | | /products/([0-9a-9AzA-Z-]+)\.html | | forward:/product/detail.html?productId=$1 | |
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 -
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 |
---|
heading | 0 |
---|
enableHeadingAttributes | false |
---|
enableSorting | false |
---|
class | m5-configuration-tree |
---|
enableHighlighting | false |
---|
|
Node name | Value |
---|
|
| |
| |
| |
| | travel.de | | forward:/de/travel | |
| | travel.fr | | forward:/fr/travel | | info.magnolia.virtualuri.mapping.HostBasedVirtualUriMapping | | / | | forward:/en/travel | |
...
| GoogleSitemapVirtualUriMapping |
---|
|
...
| GoogleSitemapVirtualUriMapping |
---|
|
Google Sitemap
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:
...
class
| Javadoc resource link |
---|
className | info.magnolia.module.googlesitemap.config.mapping.SiteMapVirtualUriMapping |
---|
renderType | asynchronous |
---|
|
compares source URI to names of sitemaps available in googleSitemaps workspace and prepends the prefix. |
prefix
| Prefix prepended by the class. |
...
Mappings in the default installations of Magnolia
...