AEM : Advanced ETC Mapping

Kinjal P Darji
2 min readDec 16, 2021

--

We came across a very unique requirement to have two domains serving the same contents but using different url structure. In almost every AEM projects, we have multi-domain requirements to support different websites of the same client and optimize the infrastructure and development efforts. Mostly these are something like below

  1. Site 1

domain : www.abc.com/en

content path : /content/abc/us/en

2. Site 2

domain : www.xyz.com/en

content path : /content/xyz/us/en

How this can be achieved with internal url rewriting is explained in very much details at this blog.

The problem

However, there’s this one scenario detailed below which not discussed anywhere at all.

  1. Site 1

domain : www.abc.com/en

content path : /content/abc/us/en

2. Site 2

domain : www.xyz.com/content/abc/us/en

content path : /content/abc/us/en

Now, to implement this we would usually have etc mapping as shown in below image.

Path : /etc/map/http

Which will completely fail, because, sling internally makes use of TreeSet to store the mapping and patterns. Here since it is TreeSet sorting of mapping and patterns happens on the basis of the length of the value of sling:internalRedirect configured. This will result in to the first domain www.abc.com being resolved for all the urls on www.xyz.com and any assets with full content paths will not render correctly because it will always internally try to prefix /content/abc/us making it /content/abc/us/content/abc/us/en as internal path for the assets.

The solution

Configure etc mapping as shown below.

--

--

Kinjal P Darji

Hi, I am an AEM architect and a certified AWS Developer — Associate.