April 26, 2020
Estimated Post Reading Time ~

Map multiple domains to one AEM instance

AEM which is based on Apache Sling [1] provides the necessary functionality through repository-based configuration. When resolving resources, these so-called mappings are applied.

The following example configuration is based on the Geometrixx website that comes per default with an AEM installation. The Geometrixx website is already multilingual and serves perfectly as an example.

The goal is to configure these mappings:
----------------------------------------------------------------
        Domain                         Content branch
----------------------------------------------------------------
www.geometrixx.fr         /content/geometrixx/fr
www.geometrixx.de        /content/geometrixx/de
----------------------------------------------------------------
These nodes have to be created in the default workspace of the repository via the CRX Content Explorer, required nodetypes in brackets:

/etc
   /map                       (sling:Folder)
      /http                   (sling:OrderedFolder)
         /www_geometrixx_fr   (sling:Mapping)
         /www.geometrixx.fr   (sling:Mapping)
         /www_geometrixx_de   (sling:Mapping)
         /www.geometrixx.de   (sling:Mapping)

2 mappings are required:

map the root context to the index-page of the language branch, e.g. www.geometrixx.fr --> /content/geometrixx/fr.html
map resources to the corresponding language branch
Following is the JSON representation of the configuration necessary to map these 2 domains (/etc/map/http.tidy.-1.json):

{
"jcr:primaryType": "sling:OrderedFolder",
"www_geometrixx_fr": {
"sling:internalRedirect": [
"/content/geometrixx/fr.html"
],
"jcr:primaryType": "sling:Mapping",
"sling:match": "www.geometrixx.fr/$"
},
"www.geometrixx.fr": {
"sling:internalRedirect": [
"/content/geometrixx/fr",
"/"
],
"jcr:primaryType": "sling:Mapping"
},
"www_geometrixx_de": {
"sling:internalRedirect": [
"/content/geometrixx/de.html"
],
"jcr:primaryType": "sling:Mapping",
"sling:match": "www.geometrixx.de/$"
},
"www.geometrixx.de": {
"sling:internalRedirect": [
"/content/geometrixx/de",
"/"
],
"jcr:primaryType": "sling:Mapping"
}
}


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.