Resource mapping is used to define redirects, vanity URLs, and virtual hosts for AEM.
For example, you can use these mappings to:
/contentso that the internal structure is hidden from the visitors to your website.
/content/en/gatewaypage of your website are redirected to
One possible HTTP mapping prefixes all requests to
/content. A mapping like this could be used to hide the internal structure from the visitors to the website as it allows:
To be accessed using:
As the mapping automatically adds the prefix
Vanity URLs do not support regex patterns.
The mappings form two lists that the JCR Resource Resolver evaluates (top-down) to find a match.
These lists can be viewed (together with configuration information) under the JCR ResourceResolver option of the Felix console; for example,
Shows the current configuration (as defined for the Apache Sling Resource Resolver).
This lets you enter a URL or resource path. Click Resolve or Map to confirm how the system transforms the entry.
Resolver Map Entries
The list of entries used by the ResourceResolver.resolve methods to map URLs to Resources.
Mapping Map Entries
The list of entries used by the ResourceResolver.map methods to map Resource Paths to URLs.
The two lists show various entries, including those entries defined as defaults by the applications. These entries often aim to simplify URLs for the user.
The lists pair a Pattern, a regular expression matched to the request, with a Replacement that defines the redirection to impose.
For example, the:
To redirect a request:
New mapping definitions are created within the repository.
There are many resources available that help explain how to define regular expressions. For example, https://www.regular-expressions.info/.
In a standard installation of AEM you can find the folder:
This folder is the structure used when defining mappings for the HTTP protocol. Other folders (
sling:Folder) can be created under
/etc/map for any other protocols that you want to map.
To create the mapping that prefixes any request to https://localhost:4503/ with
Using CRXDE navigate to
Create a node:
This node type is intended for such mappings, though its use is not mandatory.
Click Save All.
Add the following properties to this node:
Click Save All.
This mapping handles a request such as:
You can use
/etc/map.publish to hold the configurations for the publish environment. These configurations must be replicated, and the new location (
/etc/map.publish) configured for the Mapping Location of the Apache Sling Resource Resolver of the publish environment.