Expand my Community achievements bar.

AEM links not mapped when page does not exist

Avatar

Level 3

Hello,

 

I have a problem with AEM links rewriting. I have a set of mappings that works correctly for my site. All links in content are mapped nad works fine.

 

The problem happened when my component (for example core components RTE) links to a page that is not published. In that case link is not mapped and I can see in cached HTML file that the link is `/content/my-site./en/not-existing` isntead of `/en/not-existing`. When I publish `not-existign` page and clear cache link is correctly mapped.

 

Is that a new feature of AEM / Sling mappings? Can I change that ? I would like to avoid having unmapped links even if they points to 404 page. 

 

AEM 6.5.9

 

Link checker transformer config:

<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"
linkcheckertransformer.strictExtensionCheck="false"
linkcheckertransformer.rewriteElements="[a:href,area:href,form:action,img:src,link:href,script:src]"
linkcheckertransformer.stripExtensionPathBlacklist="[]"
linkcheckertransformer.disableRewriting="false"
linkcheckertransformer.disableChecking="true"
linkcheckertransformer.stripHtmltExtension="true"
linkcheckertransformer.mapCacheSize="5000"/>

 

2 Replies

Avatar

Community Advisor

Hi @bartek_887, I did quick check on my local AEM instance. I was able to configure sling mappings in the way, that all the links including the one that are pointing to not existing pages are correctly mapped/rewritten. I have used OOTB we-retail for that exercise.

Below is the mapping configuration I have tested. I have also used exactly the same Day CQ Link Checker Transformer to the one you have provided in your message.

<?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:Mapping"
    sling:internalRedirect="[/content/we-retail/us/en]">
    <redirect
	jcr:primaryType="sling:Mapping"
    	sling:internalRedirect="[/content/we-retail/us/en/$1,/$1]"
    	sling:match="(.+)$"/>
</jcr:root>

Alternatively you can consider to enable checking functionality of Link Checker, in that case broken/not existing links will not be shown at all. To do this you need to change linkcheckertransformer.disableChecking to false.

Avatar

Level 3

Could you please let me know what exactly did you check? It seems that this problem is related to `.html` extension in the mapped link. Behaviour I noticed:

  • When component renders link with `.html` extension it is always mapped
  • When component renders link without .html extension the link is mapped only when link page actually exists
    • link to existing page is mapped
    • link to not existing page is not mapped
    • This can be tested with Core Components Text component (I removed .html manually from CRX for the purpose of the test)