October 13, 2020
Estimated Post Reading Time ~

Externalizing URLs in AEM

In this article, we will discuss how we can configure an Externalizer and use it in AEM code. Let's understand what is the use of Externalizing the URLs.

Externalizer is an OSGI service using which we can update a resource path (e.g. /content/mycompany/my/page ) into an external and absolute URL (for example, https://www.mycompany.com/content/mycompant/my/page ) by prefixing the path with a pre-configured DNS.

As the instance in which the application is running can’t know its externally visible URL if it is running behind a web layer, and because sometimes a link has to be created outside of the request scope, this service provides a central place to configure those external URLs.

Configuration:
Navigate to /system/console/configMgr and configure the URL you want to use as part of the externalizer by mapping it in the Domains option.

<unique-name> [scheme://]server[:port], where:
  • scheme is usually http or https.
  • server is the hostname.
  • port (optional) is the port number.
Using the Externalizer in AEM Code:

@Reference
Externalizer externalizer;

Externalizer externalizer = resourceResolver.adaptTo(Externalizer.class);
externalizer.publishLink(resolver, "/my/page") + ".html";
externalizer.authorLink(resolver, "/my/page") + ".html";


By aem4beginner

No comments:

Post a Comment

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