Friday 13 November 2015

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 a AEM installation. The Geometrixx website is already multilingual and serves perfectly as 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:
1
2
3
4
5
6
7
/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):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
  "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"
  }
}

No comments :

Post a Comment