Question

A CQ5 instance hosts multiple websites in different content branches. How is it possible to map a domain to a specific content branch to support multi-domain hosting scenarios?

Answer, Resolution

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

/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"
  }
}

Attached there is also a Content Package [2] with above example configuration.

Applies

CQ5.2.x, CQ5.3

[1] Apache Sling"s Flexible Resource Resolution
[2] geometrixx_domain_mapping.zip

Изтегляне

Този материал е лицензиран под лиценз Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported  Публикациите в Twitter™ и Facebook не попадат под клаузите на Creative Commons.

Правни бележки   |   Правила за онлайн поверителност