0
votes

Issue image I’m having this issue when Using a standard RTE plugin hyperlink feature in AEM.

Clicking on the < ahref> links work correctly where it routes me to a correct shortened URL (/usa-en/delete/smart-factory.html) as expected.

However hovering on the link or view source of the markup generated seems to an issue where links shows an absolute path with (/content/te-com/usa/en/pages/….) which is impacting our SEO.

In fact Only the first link is getting shortened and all other links show an absolute path (/content/te-com/... path) when I hover over the links. I suspect that the cached links have an issue with the path getting shortened.

Node storage in JCR:

<p>Hello <a href="/content/te-com/usa/en/pages/delete/smart-factory.html">one</a> and <a href="/content/te-com/usa/en/pages/delete/pgp-test0.html">two</a>.&nbsp;</p>

Generated HTML markup from source :

<div class="global-rte-std-bold global-labels parbase section"><p>Hello <a href="/usa-en/delete/smart-factory.html">one</a> and <a href="/content/te-com/usa/en/pages/delete/pgp-test0.html">two</a>.&nbsp;</p>

However when I add a shift + Enter when using the RTE a
tag is added and the URL somehow gets shortened for all the links as expected as shown in the below markup. Node storage is still the same as above like the one without shift+enter

Markup Generated (observe that the URL's are shortened): <div class="global-rte-std-bold global-labels parbase section"><p>Hello <a href="/usa-en/delete/smart-factory.html">one</a> and<br><a href="/usa-en/delete/pgp-test0.html">two</a>.&nbsp;</p>

Also we have the below rewrite rule in Apache that actually comes into effect when I click the link. I suspect the cached URL's with RTE have this issue.

RewriteRule ^/?usa-en/?(.*)$ /content/te-com/usa/en/pages/$1 [PT,QSA].

Note : We have not customized the RTE plugin and its a standard Hyperlink plugin we have been using on AEM 6.2

Code used here is a simple

I wonder how it works correctly with a shift + Enter and not when I have the links on the same line.

Any help on this would be appreciated. Thanks

1
We are not using /etc/maps to shorten the URLaem_analyst
What does the resource resolver say when you try to map those URLs? There's a tool in the Felix OSGi console at http://<host>:<port>/system/console/jcrresolver that allows you to test resource resolution and mapping. It also lists all the rules applied to the tested URL and their locations.toniedzwiedz
Also, your HTML snippets are unreadable. Please format them by indenting by 4 spaces or using the grave accent character so that we can see the HTML elements as code.toniedzwiedz
Hi @toniedzwiedz,aem_analyst
Made the code readable now. resource resolver is not giving me the full path . I guess thats becuase Shortening logic is at the Apache level . I've added that rule above as wellaem_analyst

1 Answers

0
votes

When you link an internal page/asset with RTE editor then url shortening does not work. I came across the same situation and for this I had to write custom Sling rewriter to transform the link so that resourceResolver.map(path) works fine.

 @Override
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
   int hrefIndex = atts.getIndex("href");
    String href = atts.getValue("href");
  atts.setValue(hrefIndex, resolver.map(href));
}