anchor tag href value shortening inconsistently | Community
Skip to main content
Mar 23, 2023 6:52 AM UTC
Solved

anchor tag href value shortening inconsistently

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.
kaikubad
kaikubadAccepted solution
New Participant
Mar 23, 2023 7:36 AM UTC

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

DPrakashRaj
New Participant
Mar 25, 2023 3:42 AM UTC

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 

Translate
Ritesh_Mittal
New Participant
Mar 23, 2023 8:38 AM UTC

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

Translate
kaikubad
kaikubadAccepted solution
New Participant
Mar 23, 2023 7:36 AM UTC

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.

Translate