Right way of using short URL for multiple domains | Community
Skip to main content
New Participant
January 15, 2024
Solved

Right way of using short URL for multiple domains

  • January 15, 2024
  • 5 replies
  • 8664 views

Hello Team,
There are lots of information available for the short URL implementation. Wanted to know the right approach.

My scenario:
My project handles various domains. each content hierarchy supports various domain site.


abc.com
/content/client/abc/en

xyz.com
/content/client/xyz/en

pqr.com
/content/client/pqr/en


Short URL is handled via Apache Sling Resource Resolver Factory, Dispatcher configuration
In the Apache Sling Resource Resolver Factory configuration, we have added these values for publish env. run mode ( only for prod publish)
^/content/client/abc/(.+).html</$1.html
^/content/client/xyz/(.+).html</$1.html
^/content/client/pqr/(.+).html</$1.html


Then, in the Dispatcher, for each domain, we have separate redirect conf file.
So, in each file we have written these line for the re direction
RewriteRule ^/$ /en/home.html [R=301,NC,L]

This works perfect for all our sites. Even in any component, if we use internal page path then while on hovering the link, this shows short URL. This is good one.
However, I have noticed that short URL is enabled in prod publish environment. In this case, if I click on any menu(where we are showing the page hierarchy as menu, menu item), this goes to short URL. and then shows 404 response. Then, manually I need to use the long URL.
Anyhow, this is not a major blocker. Since, authors, testers use Prod author, then live site URL. Only developers are using prod publish for testing few pages.

Is this, the right approach? Can I utilize Sling Mappings – under etc/map

Checked these sites. But, still have confusion.
https://helpx.adobe.com/in/experience-manager/kb/multi-domain-management-aem-mappings-for-url-shortening---aem-6-.html
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-url-shortening-functionality/m-p/305586

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

@mahesh_gunaje 

 

The best option is to use Sling Mappings.

  • Can cover complex rewrites which involve:
    • multi-tenant set-up
    • Also, shortens links in HTML

 

Jorg Ho has already shared the comparison on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-url-shortening-functionality/m-p/305586 

 

You can also refer to https://www.youtube.com/watch?v=bJ_cXcAE7G8&t=611s&ab_channel=TechForum. Here they have discussed with example about the challenges with "Apache Sling Resource Resolver Factory" approach

5 replies

kautuk_sahni
Employee
January 16, 2024

@mahesh_gunaje Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
arunpatidar
New Participant
January 16, 2024

Hi @mahesh_gunaje 
I think whatever you have implemented is the right approach.

The use case you are talking about is rare but can be handled as well. but you need to think about what you would get v/s effort.

 

One of the solutions would be to send custom request headers to Publish to identify and based on that you do url shortening/remapping. e.g. if you are accessing the page via dispatcher add a custom request header. so that AEM can do url shortening.

Arun Patidar
aanchal-sikka
aanchal-sikkaAccepted solution
New Participant
January 16, 2024

@mahesh_gunaje 

 

The best option is to use Sling Mappings.

  • Can cover complex rewrites which involve:
    • multi-tenant set-up
    • Also, shortens links in HTML

 

Jorg Ho has already shared the comparison on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-url-shortening-functionality/m-p/305586 

 

You can also refer to https://www.youtube.com/watch?v=bJ_cXcAE7G8&t=611s&ab_channel=TechForum. Here they have discussed with example about the challenges with "Apache Sling Resource Resolver Factory" approach

Aanchal Sikka
New Participant
January 16, 2024

You will need to provide URL mapping for incoming request as well which will resolve to full url. But for your mapping it will be hard to resolve. 

Instead you can try this

^/content/client/abc/(.+).html</abc/$1.html
^/content/client/xyz/(.+).html</xyz/$1.html
^/content/client/pqr/(.+).html</pqr/$1.html

 

^/content/client/abc/$1.html>/abc/(.+).html
^/content/client/xyz/$1.html>/xyx/(.+).html
^/content/client/pqr/$1.html>/pqr/(.+).html

 

I have not tested this.

Raja_Reddy
New Participant
January 15, 2024

Hi @mahesh_gunaje 

please check below url : 

https://blog.3sharecorp.com/shortening-urls-in-aem

 

Thanks.