anchor tag href value shortening inconsistently | Community
Skip to main content
March 23, 2023
Solved

anchor tag href value shortening inconsistently

  • March 23, 2023
  • 3 replies
  • 870 views

Hi,

 

I am currently using AEM 6.5.13. I am trying to render some links using "href" in anchor <a> tag.

 

Sample code:

 <a href="${slingObject.link}"/>

 

This link has 2 values coming from backend,

/content/marketA/index/pageA.html 

/content/marketB/index/pageB.html

Now the href value comes in this format in BROWSER through dispatcher URL, which is clearly inconsistent

In case A,  <a href="/content/marketA/index/pageA.html"/>

while in case B, <a href="pageB.html"/>

 

These markup are part of DOM loading on some other page hierarchy, say mysite.com which corresponds to /content path.

 

When I click on the links, the URL it tries to fetch is,

Case A: www.mysite.com/content/marketA/index/pageA.html response 200 and page renders

Case B: www.mysite.com/content/pageB.html response 404 and page does not renders.

 

In my opinion, the behavior should be consistent. I have tried following:

1. Check how it is being rendered in Author and Publish: Full path shows up in the DOM

2. Check what has been cached in the dispatcher: Full path again getting cached.

 

What could be the issue ?

 

 

 

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 kaikubad

It seems you are having issue with Map.

 You can check following..

1. Before sending the link from backend  use resourceResolver.map(link);

2. Check dispatcher rule because from dispatcher we generally hide /content/sitename

 

if you use resourceResolver.map(link) i think your problem will be solved.

3 replies

kaikubad
Community Advisor
kaikubadCommunity AdvisorAccepted solution
Community Advisor
March 23, 2023

It seems you are having issue with Map.

 You can check following..

1. Before sending the link from backend  use resourceResolver.map(link);

2. Check dispatcher rule because from dispatcher we generally hide /content/sitename

 

if you use resourceResolver.map(link) i think your problem will be solved.

Ritesh_Mittal
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
March 23, 2023

Hi @17651616 ,

 

Please check if you have 'URL mapping' added to 'Apache Sling Resource Resolver Factory' or custom link rewriter added to your project. Please use below videos for reference-

 

https://www.youtube.com/watch?v=zcKwRTZ78_Y&list=PLzwWOJSdKWBf7zLga8P7-ARxFQRwGGd94&index=29

 

https://www.youtube.com/watch?v=0fM2vUEj2bA&list=PLzwWOJSdKWBf7zLga8P7-ARxFQRwGGd94&index=30

 

Thanks,

Ritesh Mittal

DPrakashRaj
Community Advisor
Community Advisor
March 25, 2023

Are you seeing this issue on author, publisher or dispatcher or on all 3.

on author and publisher it should start with /content/sitename/locale/page.html and on dispatcher it should be without /content/sitename