Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Automatically rewrite links to remove /content/ path?

Avatar

Level 2

I have a website where the site structure is /content/mysite/us/en/page.html.

 

I have the following sling mapping set up so the site can be served without /content/ in the path at https://example.com/mysite/us/en/page.html:

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:mixinTypes="[cq:ReplicationStatus,sling:MappingSpec]"
    jcr:primaryType="nt:folder"
    sling:internalRedirect="[/content/mysite/$1/$2/$3]"
    sling:match="mysite/([a-z]{2})/([a-z]{2})/(.*)"/>

 

The problem is, when I view the site without the /content/ path in the URL, all the links on the page still contain /content/ in them. How do I implement the feature so that /content/ is automatically removed from all link element attributes when the URL does not contain /content/ in it?

 

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 5

You need to write a service to process the links based on whatever the criteria you want.

Now in each of the component/places where you use any link, call that service to process the link and return the updated link that you get from the service.

View solution in original post

0 Replies

Avatar

Correct answer by
Level 5

You need to write a service to process the links based on whatever the criteria you want.

Now in each of the component/places where you use any link, call that service to process the link and return the updated link that you get from the service.

Avatar

Level 6

Hi @nydel09  You need to implement sling reverse mapping for this that will resolve the issue.

Please refer this article for reverse sling mapping to remove /content reference inside the rendered web pages

https://www.albinsblog.com/2020/07/configure-sling-mapping-for-resource-resolution-in-adobe-experien...

 

Regards,

Rajashankar.R