AEM 6.2: Url Shortening using sling mapping for multi-language site | Community
Skip to main content
Level 4
December 21, 2017
Question

AEM 6.2: Url Shortening using sling mapping for multi-language site

  • December 21, 2017
  • 4 replies
  • 2991 views

Hi All,

I have a use case for url shortening for my multi-language site (Url mapping I am able to solve . Problem is only with shortening in links and hrefs). Would like to hear from you guys if this is achievable or not with Sling mappings.

My page structure and expected shortened url from anchor tags  is as follows.

/content/<companyname>/en/abc.html --> www.<companyname>.com/abc

/content/<companyname>/en/xyz/def.html --> www.<companyname>.com/def

/content/<companyname>/es/abc.html -->www.<companyname>.com/es/abc

/content/<companyname>/es/xyz/def.html -->www.<companyname>.com/es/def

Basically for non english pages i want to have the language code prepended before the page name.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

Community Advisor
December 22, 2017

Please check the Rewriting is not disabled in Day CQ Link Checker Transformer and change the Rewrite Elements configuration as required. This will rewrite all the link and href URL's to shorten URL's as configured in the Sling Mappings.

Regards

Albin I

www.albinsblog.com

a_mn1Author
Level 4
December 24, 2017

Hello Albin, the question is on the feasibility of writing a regex for Url shortening. I know I can write a regex to match the inbound requests and map them to resources.  I need to know if outbound can be controlled using a regex

edubey
Level 10
December 28, 2017

You should be able to rewrite all those links (href), if you are using org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl and

resolve.map() from resource resolver when creating them

Level 3
December 29, 2017

Yup that is completely feasible. Sling Mappings are designed for exactly that purpose, you just need to write correct regular expression.

But my question is - do you really need that xyz transformation? As far as I can tell ommiting xyz in path might get conflict with another zyx folder in the same lever having the same page name. I am just making sure that its what you have designed, because if it will turn out that this was a just mistake and you need to get back to original path architecture would be quite hard to preserve old links with new one (if you care at all).