AEM SPA Short link implementation | Community
Skip to main content
Level 3
August 4, 2023
Solved

AEM SPA Short link implementation

  • August 4, 2023
  • 1 reply
  • 1131 views

Hi, AEM SPA application doesn't load when we change the URL through redirect or link shorting. Example, changing link from localhost:4502/content/project/us/en/pagename.html to localhost:4502/us/en/pagename.html. Page doesn't throw error but it's just blank page.

 

I saw some other questions on this forum explaining to change HierarchyPage model method getExportedPath(). 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-spa-react-dispatcher-setup/m-p/384035

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/short-urls-using-react-spa/td-p/453377

 

Based on Google Search I came across HierarchyPage class. 

https://github.com/adobe/aem-sample-we-retail-journal/blob/master/bundles/core/src/main/java/com/adobe/cq/sample/spa/journal/internal/models/HierarchyPageImpl.java  

 

I have changed the getExportedPath().

 

public String getExportedPath() { System.out.println(currentPage.getPath()); String pagePath = currentPage.getPath(); if(pagePath.contains("/content/project")){ String trimmedPagePath = pagePath.replace("/content/project",""); return trimmedPagePath; } else{ return currentPage.getPath(); } }

 

 

but still redirect or page sortlink doesn't work. Is this the correct implementation? or can someone share their custom page model implementation for the spa redirect/linkShorting.

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 DPrakashRaj

Please have a look to implement url shortening in aem react spa http://experience-aem.blogspot.com/2021/10/aem-cloud-service-url-shortening-of-react-spa.html

1 reply

DPrakashRaj
Community Advisor
DPrakashRajCommunity AdvisorAccepted solution
Community Advisor
August 4, 2023

Please have a look to implement url shortening in aem react spa http://experience-aem.blogspot.com/2021/10/aem-cloud-service-url-shortening-of-react-spa.html

iamnjain
Community Advisor
Community Advisor
November 16, 2023

Hi @dprakashraj 

 

I tried above sample project mentioned in the article, but as soon we change the hierarchical structure depth to 0, in template page policy. It stops working.

@moiezmadid you found any solution to get it working?