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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Link Rewriting not working for custom attributes on most of the elements

nikeshpshindhe
Level 2
Level 2

Hi Everyone,

I have added sling mappings to shorten urls for content pages and for the assets under dam, the mapping rules are working fine and i am able to validate on tool http://localhost:4503/system/console/jcrresolver. but when i am trying to validate the rule on component the mapping is not working for most of the custom element:attribute entries added within link checker transformer config.

 

linkcheckertransformer.rewriteElements=["div:data-asset","div:some-attr","a:cust-attr","a:cust-attr2","a:href","area:href","form:action","img:src","img:srctest","link:href","script:src","img:testit","p:testit"]

 

 

1 Accepted Solution
kchaurasiya
Correct answer by
Level 6
Level 6

@nikeshpshindhe : You can also check the below configuration.

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
contentTypes="[text/html]"
enabled="{Boolean}true"
generatorType="htmlparser"
order="1"
serializerType="htmlwriter"
transformerTypes="[linkchecker,versioned-clientlibs,custom]"/>

Here is the path for the above config. Please see the below snapshot for the reference.

kchaurasiya_0-1628095414588.png

 

Thank You.

Keshav 

View solution in original post

7 Replies
markus_bulla_adobe
Employee
Employee

Hi @nikeshpshindhe!

Shortening URLs consists of two different mechnisms:

  1. Mapping of incoming HTTP requests
  2. Rewriting of links in the generated HTML

1. The first part is responsible to make sure that a request to yourdomain.com/home.html will be mapped to the correct resource path on AEM side, e.g. /content/mytenant/us/en/home. Depending on your specific requirements and setup, this can be handled on AEM side (Sling Mappings) or on web server level (mod_rewrite).

2. The second part is responsible to adjust all links, references, etc. in the generated, outgoing HTML source code. The rewriting makes sure, that your links are pointing to the shortened URL (e.g. /home.html) instead of the full resource path (e. g. /content/mytenant/us/en/home.html).

 

From your explanation I understand that mapping (1) seems to work as expected but rewriting (2) has issues with custom tags and/or attributes.

There are a couple of things that you can check:

  • Check on the filter chain (can be retrieved from the "Recent Requests" view at /system/console/requests) to see if the rewriter is actually picked up.
  • Double check on the rewriter configuration and that it is actually picked up.
  • Try to increase the log level for the rewriter and see if debug logging gives additional insights.

Hope that helps!

nikeshpshindhe
Level 2
Level 2

Hi Markus, Thanks for looking into this post.

 

  • i have tried setting the log for com.day.cq.rewriter.linkchecker on debug mode, and i can only see the rewrite entries for page paths(for only href,src not for any other custom attributes) there is not entry for the asset paths
  • I am adding the attibutes entry in Day CQ Link Checker Transformer config not sure if you are referring to something else here "Double check on the rewriter configuration and that it is actually picked up"
nikeshpshindhe
Level 2
Level 2
i have tried setting the log for com.day.cq.rewriter.linkchecker on debug mode, and i can only see the rewrite entries for page paths not for the asset paths
kchaurasiya
Level 6
Level 6

@nikeshpshindhe , Have you added the link-checker config service under the configuration. If yes you can compare with below things and if not then you can check and add the same.

 

I have added this link check in AEM 6.4 as per the below.

 

Step 1 : created the com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl.xml configuration under the config parallel to the components folder.

Step2 : content of the file: Just check custom attributes for the reference.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
service.check_override_patterns="[^system/.]"
service.special_link_prefix="[javascript&colon;,data:,mailto:,#,&lt;!--,${,http://,https://,tel:]"/>

Thank You.

Keshav 

kchaurasiya
Correct answer by
Level 6
Level 6

@nikeshpshindhe : You can also check the below configuration.

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
contentTypes="[text/html]"
enabled="{Boolean}true"
generatorType="htmlparser"
order="1"
serializerType="htmlwriter"
transformerTypes="[linkchecker,versioned-clientlibs,custom]"/>

Here is the path for the above config. Please see the below snapshot for the reference.

kchaurasiya_0-1628095414588.png

 

Thank You.

Keshav 

View solution in original post

kchaurasiya
Level 6
Level 6
@nikeshpshindhe : I have updated the path of the config in the answer. Please check it. Thanks Keshav