Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Handling multiple domains using Externalizer

Avatar

Level 4

Hello All - Is there a way to configure the externalizer for multiple publish domains? We have 4 domains in our project and would like to maintain the externalizer config based on run-modes. In the externalizer config it says, we need to specify publish followed by domain to specify the configs. i.e 

publish www.example1.com

publish www.example2.com

publish www.example3.com

publish www.example4.com

How can I specify the configs. Since all are different domains.

 

com.day.cq.commons.impl.ExternalizerImpl

 

5 Replies

Avatar

Level 2

Have you explored context-aware configuration for your problem? I believe you should be able to create separate configs for different paths of your repository.

Avatar

Level 4
@mayank_saklech1 - Actually the same content slice (i.e /content/test/en/) is used for all four sites. we cannot use context-aware here as the path is same.

Avatar

Community Advisor

Hi @aemninja 

 

You can define it in the OOTB configuration.i.e., with com.day.cq.commons.impl.ExternalizerImpl.xml and add the domain names. In your code you can read the configuration by passing the domain name.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
externalizer.domains="[author http://localhost:4502,publish http://localhost:4503,website1 https://www.website1.com,website2 https://www.website2.com]"/>

 

Thanks! 

Avatar

Community Advisor

@aemninja  Once you define various domains in externalizer, you would be able to refer those in the code as below:

String myExternalizedUrl = externalizer.externalLink(resolver, Externalizer.LOCAL, "/my/page") + ".html";