Blogs > ETC Mapping in AEM

AEM Sites

ETC Mapping in AEM

Infodales Tech Solutions | October 25, 2024

Overview

In AEM (Adobe Experience Manager), ETC Mapping is primarily used for routing or transforming content based on a defined mapping between the source and the destination locations in the repository. The term ETC refers to "Experience Targeted Content", which is used to manage how content is structured, served, or redirected within AEM.

What is ETC Mapping in AEM ?

In the context of Adobe Experience Manager (AEM), ETC Mapping typically refers to the Experience Targeted Content (ETC) system, which is used to map content or redirect requests to different locations or resources based on specific conditions, such as user profile, geographical location, or language preferences. However, ETC Mapping is not a standard, widely recognized term in AEM documentation. It might be referring to a specific implementation within your organization or an alias for content mapping used in certain workflows.

Request-Resource Mapping

    resource-request-mapping

    Local Domain Setup:

    • In the setup, a local domain is configured.

    • A user requests this domain in their browser.

    Request Reaches Apache Server:

    • The request is first directed to the Apache server.

    • However, the Apache server does not know what specific content should be served for the requested domain.

    Request Moves to AEM:

    • Since Apache lacks this information, it forwards the request to the AEM server.

    AEM Resolves the Content:

    • AEM serves the identified content back to the client (browser).

    • This completes the request-response cycle.

    request-resource-mapping-with-url

    Client Request:

    • The client requests a page using the URL: public:4503/women.html.

    Request Reaches Apache Server:

    • The request is first directed to the Apache server.

    • The Apache server, however, does not know what specific content should be served for the requested URL

    Request Forwarded to AEM:

    • Since the Apache server cannot resolve the content, it forwards the request to the AEM server for handling.

    AEM Resolves the Content Path

    • In AEM, the requested URL /women.html is mapped to the actual content path: /content/we-retail/us/en/women.html.

    • This mapping ensures that AEM serves the correct content for the requested page.

    URL Rewriting:

    • AEM automatically hides the internal content structure (/content/we-retail/us/en) in the URL, presenting a cleaner and user-friendly URL (/women.html) to the client.

    Response Sent to Client:

    • AEM serves the content at /content/we-retail/us/en/women.html back to the client, but the client sees the cleaner URL public:4503/women.html.

    How ETC Mapping Works:

    • ETC Mapping in AEM facilitates this process by defining the rules for mapping short, user-friendly URLs to the actual internal content paths..

    • This process is also known as URL rewriting in AEM.

For the local setup, add the domain to the host file:

  • Navigate to C:\Windows\System32\Drivers\etc\hosts.

  • Add the following entry: 127.0.0.1 publish.4503.

Steps to Create ETC Mapping in AEM

  • Login in to the publish instance

  • Open the CRX/DE Lite interface in your browser:

  • http://localhost:4503/crx/de/index.jsp.

Navigate to the ETC Mapping Node:

  • Go to the path: /etc/map.

Create a New Node for the Domain:

  • Under /etc/map, create a new node for the domain (if it does not exist).

  • Example: If your domain is public, create a node named http (for HTTP domains) or https (for HTTPS domains).

  • Inside this node, create another node for the specific domain this node should be of type “sling:Mapping”, e.g., public.

  • etc-map-node-path

Configure Properties for the Mapping Node:

    AEM-tools-page

Add the following properties to the mapping node:

  • sling:internalRedirect: If the domain name matches the node name, we use sling:internalRedirect. When you enter the domain name in the browser, it internally redirects to the specified content path.

Create a node for Clientlibs:

Create a new node under the publish node, and name it, for example, etc_clientlibs. Add the following properties to the mapping node:

  • Set the value of sling:match to etc[.]clientlibs/(.+).

  • Set the value of sling:internalRedirect to /etc.clientlibs/$1.

When the node name does not match the domain name, we use the sling:match property. In this case, sling:match captures everything after the domain (matching etc[.]clientlibs/(.+)) and stores it in a variable. This variable ($1) is then resolved and appended in the sling:internalRedirect property, such as in /etc.clientlibs/$1. Here, $1 corresponds to whatever matches (.+) in the sling:match property.

    etc-map-node-path

Click Save All. Then, access http://publish:4503 in your browser, and you will be redirected to the home page.

    home-html-image

Create a node under the http folder, for example, named publish_home (of type sling:mapping).

Add the following properties to this node:

  • sling:internalRedirect: /content/we-retail/us/en/home.html.

  • sling:match : publish.4503/$.

Explanation: As discussed earlier, any request that matches the sling:match value (in this case, publish.4503/$) will resolve to the content path specified in the sling:internalRedirect property.

    publish_home_image

Create a configuration for the rest of the pages.

Now, let's assume you are accessing domain/page.html in the browser. The path should resolve to /content/page.html, but the /content part will be hidden, displaying only /page.html. This approach is known as URL rewriting in AEM.

Modify the publish.4503 node.

Add the following values to the sling:internalRedirect property:

  • /content/we-retail/us/en

  • /

Explanation: Whenever you access publish.4503/pagename.html, the system will automatically resolve the path starting with /content/we-retail/us/en or /, hiding this part of the path. As a result, only publish.4503/pagename.html will be displayed in the browser.

    modified_publish_node

Now, if you access http://publish:4503/women.html in the browser… it looks like

    women_html_image

Conclusion:

ETC mapping in AEM is a powerful tool for optimizing URL structures, enhancing user experience, and simplifying content management by effectively handling internal redirects and URL rewriting. By leveraging properties like sling:match and sling:internalRedirect, you can create clean, user-friendly URLs that align with your project’s requirements while maintaining seamless backend functionality.


Yash Sakharkar | AEM Developer
LinkedIn Email