Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML Wrap
alignright
classmenu

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

...

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

Regular expression

Take requested page name and pass it as a productId request parameter to a product detail page.

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
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-9A9a-zA-Z-]+]) which can be referenced in the toUri using $1.

...