Expand my Community achievements bar.

SOLVED

Sling mapping multi language site

Avatar

Level 2

Hi,

I've tried searching the forum, but did not find an answer to my question.

We have a multi language site, with two languages English and Spanish.

Our site structure is as follows:

content

     |----mysite

               |-------es

                         |----... (spanish pages)

               |-------en

                         |----... (english pages pages)

The default urls are something like this:

    www.myhost.com/content/mysite/en/welcome.html

By using sling mappings I would like to become the following:

   www.myhost.com/en/welcome.html

So get rid of the /content/mysite/ part en keep the locale.

Using the following sling mapping, I am able to get rid of the /content/mysite/en part

<?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/mysite/en/(.*)]"

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

The link checker (transformer) rewrites the menu links to:

   www.myhost.com/welcome.html and these links work.

But when I want to keep the locale, with the following mapping:

<?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/mysite/(.*)]"

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

I get links like this: www.myhost.com/en/welcome.html, but these result in a 404.

The log shows the following message:

GET /content/mysite/en/en/welcome.html HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Resource /content/mysite/en/en/welcome.html not found

Somehow the locale is duplicated now.

Can someone explain me what I'm doing wrong ?

Thanks for your help!

1 Accepted Solution

Avatar

Correct answer by
Employee

You can try to do the same on a dispatcher level. Check Using Dispatcher with Multiple Domains and the way it describes a configuration for

| - /content

     | - sitea

     |    | - content nodes

     | - siteb

          | - conent nodes

View solution in original post

5 Replies

Avatar

Employee Advisor

If this is a part of your log message:

GET /content/mysite/en/en/welcome.html HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Resource /content/mysite/en/en/welcome.html not found

It seems to me that this was not a request to mysite.com/en/welcome.html.

Jörg

Avatar

Level 2

the point is that for the 2nd mapping; the page is not found and the logging shows the double locales.

of course I did not use the real names of the site.

Avatar

Level 2

smacdonald2008​ yes, I think I've followed the doc. correctly.

Is it possible this might be caused by the JcrResourceResolverFactory, which currently looks like this:

<?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:mixinTypes="[cq:ReplicationStatus]"
   jcr:primaryType="sling:OsgiConfig"
   resource.resolver.mapping="[/:/,/system/docroot/:/]"
   resource.resolver.map.location="/etc/mappings/map.publish.local"
   resource.resolver.searchpath="[/apps,/libs,/apps/foundation/components/primary,/libs/foundation/components/primary]"/>

Avatar

Correct answer by
Employee

You can try to do the same on a dispatcher level. Check Using Dispatcher with Multiple Domains and the way it describes a configuration for

| - /content

     | - sitea

     |    | - content nodes

     | - siteb

          | - conent nodes