Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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/campaigns/winter2016
  • Absolute

    fromUri: /winter2016
    toUri: forward:https://www.example.com/marketing/campaigns/winter2016.html

The mappings registry

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 

The mappings registry

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 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:

...

  • info.magnolia.virtualuri.mapping.*
    • Javadoc resource link
      classNameinfo.magnolia.virtualuri.mapping.DefaultVirtualUriMapping
      renderTypeasynchronous
       maps a virtual URI to a content path. This is the simplest and most common type.
      ((warning) Magnolia 5.4.6+) If the URI starts with a dot ( 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
      classNameinfo.magnolia.virtualuri.mapping.RegexpVirtualUriMapping
      renderTypeasynchronous
       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
      classNameinfo.magnolia.virtualuri.mapping.RotatingVirtualUriMapping
      renderTypeasynchronous
       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
      classNameinfo.magnolia.virtualuri.mapping.HostBasedVirtualUriMapping
      renderTypeasynchronous
       forwards the request to a different URI depending on the requested host name.
    • Javadoc resource link
      classNameinfo.magnolia.virtualuri.mapping.HostBasedRegexpVirtualUriMapping
      renderTypeasynchronous
       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.*
    • Javadoc resource link
      classNameinfo.magnolia.module.googlesitemap.config.SiteMapVirtualUriMapping
      renderTypeasynchronous
      compares source URI to names of sitemaps available in the googleSitemaps workspace and prepends the prefix.
  • info.magnolia.multisite.* 
    • Javadoc resource link
      classNameinfo.magnolia.multisite.MultiSiteRootVirtualURIMapping
      renderTypeasynchronous
       is a special class which specifies the root of a site if site matching returns null
    • Javadoc resource link
      classNameinfo.magnolia.multisite.MultiSiteRegexpVirtualURIMapping
      renderTypeasynchronous
       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
heading0
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

Node name

Value

Mgnl f
virtualUriMappings


Mgnl n
winter2010


Mgnl p
class

info.magnolia.virtualuri.mapping.DefaultVirtualUriMapping

Mgnl p
fromUri

/winter2016

Mgnl p
toUri

forward:/marketing/campaigns/winter2016

...

:/marketing/campaigns/winter2016

Regular expression

Info
iconfalse

(warning) 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
heading0
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

Node name

Value

Mgnl f
virtualUriMappings


Mgnl n
productIDs


Mgnl p
class

info.magnolia.virtualuri.mapping.RegexpVirtualUriMapping

Mgnl p
fromUri

/products/([0-9a-9AzA-Z-]+)\.html

Mgnl p
toUri

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.

...

ModuleEdition

Mapping class

From

(Site)

To
activationCE, EE

DefaultVirtualUriMapping

((warning) This is an old mapping and
will be soon removed from the default mappings.)

/ActivationHandlerforward:/.magnolia/activation

ui-admincentral

(Author Instance)

EE

MultiSiteRootVirtualURIMapping

/redirect:/.magnolia/admincentral

ui-admincentral

(Author Instance)

CE

DefaultVirtualUriMapping

/redirect:/.magnolia/admincentral

ui-admincentral

(Public Instance)

EE

MultiSiteRootVirtualURIMapping

/redirect:/travel.html

ui-admincentral

(Public Instance)

CE

DefaultVirtualUriMapping

/redirect:/travel.html
google-sitemapCE, EE

SiteMapVirtualUriMapping


redirect:/sitemaps
rssaggregatorCE, EE

RegexpVirtualUriMapping

/rssFeeds/(.*)redirect:/rss/?feedPath=/$1
rssaggregatorCE, EE

RegexpVirtualUriMapping

/planetFeeds/(.*)


redirect:/rss/?feedPath=/$1&generatorName=planet
rssaggregatorCE, EE

RegexpVirtualUriMapping

/categoryFeeds/([a-zA-Z0-9,-]*)/(.*)

redirect:/rss/?generatorName=category&categories=$1&siteRoot=/$2
toursCE

RegexpVirtualUriMapping

/tours(.*).html

forward:/travel/tour?tour=$1
toursEE

MultiSiteRegexpVirtualURIMapping


/tours(.*).html

( travel )

forward:/tour?tour=$1
toursEE

MultiSiteRegexpVirtualURIMapping

/tours(.*).html

( sportstation )

forward:/tour?tour=$1


/products/([0-9a-zA-Z-]+)\.html