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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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).
Views
Replies
Total Likes
Views
Likes
Replies