AEM 6.4 Resource Resolver Mapping home page to root | Community
Skip to main content
bmccurdy1
Level 2
Jul 29, 2019 10:25 PM UTC

AEM 6.4 Resource Resolver Mapping home page to root

This seems like a fairly common use case but we have a client that is experiencing some issues with url rewriting / shortening.

The gist is, the client would like to have all links on the site that link to the home page '/content/client-site/en/home' to map to root '/'. Also note that all content lives under this home page.

Using the resource resolver we have mappings to shorten the urls on the publish instances:

/content/client-site/en/home/(.*):/$1

/content/client-site/en/home:/

We have a few Apache rewrites on the dispatcher side to handle content shortening and redirection properly.

What the client is experiencing is when they create a link on a page back to the homepage and use a relative path in author; once published the url is mapped to '/' but a '.html' extension is being added. In short the url to the home page ends up looking like '/.html' instead of '/'.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

6 replies

Level 2
Nov 4, 2019 10:29 PM UTC

You can try something like this

One sling map rule for your Home/root page and one for your child pages

Home Page

<?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"

    jcr:primaryType="sling:Mapping"

    sling:internalRedirect="/content/client-site/en/home.html"

    sling:match="www.myDomain.com/"/>

Child Pages

<?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"

    jcr:primaryType="sling:Mapping"

    sling:internalRedirect="[/content/client-site/en/home/(.*)]"

    sling:match="www.myDomain.com/$1"/>

Translate
Himanshu_Singhal
New Participant
Jul 30, 2019 7:15 AM UTC

To handle the case, you'll have to create 2 cases here:
1. Specifically for root page
2. For all pages under home pages hierarchy.

E.g.


localhost_4503

<?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/client-site/en/home.html]"

    sling:match="www-release.newrelic.com/$"/>

localhost.4503

<?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="[/$1,/content/client-site/en/home/$1]"

    sling:match="(.+)$"/>

Using the above mentioned sling mapping cases, the root page will be delivered for domain name and for below hierarchy, the anothe rule will come in picture

Translate
bmccurdy1
bmccurdy1Author
Level 2
Aug 2, 2019 12:37 PM UTC

So, I have doubts that this suggestion will rewrite the link on the page accordingly. The issue is when there is a link on any page that redirects to the home page, when you hover over that link it appears as '/.html'. It's almost as if something is forcing extensions on all links.

I added your suggestion(s) to my local publish instance to validate, when examining the links on the page they still pointed to full path of '/content/client-site/en/home' and had not been shortened as expected.

Translate
Himanshu_Singhal
New Participant
Aug 2, 2019 12:45 PM UTC

Kindly make sure that in the configuration "Day CQ Link Checker Transformer" , Strip HTML Extension option is checked. If not, it by default adds the .html extension to url. If you'll check, it'll start stripping off .html extension from url.

And, for, url shortening not working, kindly share the mapping or please share the mapping package.

Best regards,

Himanshu Singhal

Translate