Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Sling mapping issue

Avatar

Level 2

Hi there,

When sling mapping is used there is any way to set a application order?

In our case we have a set of rules to "shorten" part of the URL and another to remove the .html at the end:

sling:internalRedirect="/content/project/xx/yy/$1.html"

sling:match="localhost.8080/(.*)$

sling:internalRedirect="/content/project/xx/yy/"

sling:match="localhost.8080/

Also we define a few rules to avoid break the resources under /bin/, /etc/, /mnt and so on
All of this rules are at the same level under, /etc/map/http

The problem we have is when we add the mapping to allow the remove of the .html

the rules added for /bin/, /etc/, /mnt/ get changed by: /project/xx/yy/[bin||etc||mnt], so for example the replication service isn't working.

Does anybody face this problem?

4 Replies

Avatar

Community Advisor

Can you share other mapping as well for /bin/, /etc/ and /mnt/ ?

you can check Apache Sling :: Mappings for Resource Resolution  docs for more in depth sling mappings.



Arun Patidar

Avatar

Level 5

Hello qglez

When considering etc mappings, you always have to remember one major consideration i.e. the dispatcher cache. The reason I am mentioning this is because it's a fairly critical implication that goes unnoticed.

Before I get to the html stripping part, I'd like to focus on the path shortening and also the fact that you don't need to write any sling mapping rules for /bin, /etc, or otherwise. When you create sling:mappings, you define a sling:InternalRedirect and in that internal redirect setting, which by the way is a string array, you define them as the following. The mappings below get resolved in a certain order until a valid hit in aem is resolved. This is the mapping which will save all your requests to /bin, /etc, /mnt. etc from getting a HTTP 404.

sling:internalRedirect=“/content/project/xx/yy/$1”,"/$1"

sling:match=“localhost.8080/(.+)$

Regarding the html extension stripping, you can do this by going to "Day CQ Link Checker Transformer" in /system/console/configMgr and select "Strip HTML Extension".

Putting these two together, you must ensure that your dispatcher is caching properly. For example, if a request comes in as http://mywebsite.com/sitea, and the dispatcher passes it along as it is, the dispatcher will cache it incorrectly and further invalidation might lead to more problems.

You should read the article http://www.cognifide.com/our-blogs/cq/multidomain-cq-mappings-and-apache-configuration/​ for a quick overview of this implementation.

I hope this helps.

Best Regards,

Aneet Arora

Avatar

Level 2

Hi, thank you for your quick responses!

Arun Patidar​ thanks, here is the current mapping we have, (appologies for the probably mess):

mapping.JPG

Name
Mapping
bin

    sling:internalRedirect="/bin/"

    sling:match="localhost.8080/bin/"

clientlibs

    sling:internalRedirect="/etc.clientlibs/"

    sling:match="localhost.8080/etc.clientlibs/"

content - dam

    sling:internalRedirect="/content/dam/"

    sling:match="localhost.8080/content/dam/"

etc

    sling:internalRedirect="/etc/"

    sling:match="localhost.8080/etc/"

html localhost.8080 - es

    sling:internalRedirect="/content/project/es/es/$1.html"

    sling:match="localhost.8080/(.+)"

libs

    sling:internalRedirect="/libs/"

    sling:match="localhost.8080/libs/"

localhost.8080 - ca

    sling:internalRedirect="/content/project/es/ca/"

    sling:match="localhost.8080/ca/"

localhost.8080 - en

    sling:internalRedirect="/content/project/es/en/"

    sling:match="localhost.8080/en/"

localhost.8080 - es

    sling:internalRedirect="/content/project/es/es/"

    sling:match="localhost.8080/"

mnt

    sling:internalRedirect="/mnt/"

    sling:match="localhost.8080/mnt/"

The idea behind the mappings on localhost - en, localhost - es, localhost - ca is:

For en and ca:

     localhost:8080/en/page.html
     localhost:8080/ca/page.html

For es is to be able to have links like:
     localhost:8080/page.html

Ones on bin, clientlibs, mnt, content - dam, etc, libs, mnt, are to avoid the a wrong mapping of the resources under those paths

The main problem comes with the html localhost.8080 - es, when we add it,

the site recognizes the previous links but it becomes kind unstable, some services are not longer recognized, such as the /bin/receive for example.

smacdonald2008​ thanks for your response,I'll try to give it a new lecture,

maybe we are having a wrong idea of how to implement or even if the idea is feasible using sling mappings.

aneeta45259594​ thanks for the detailed response.
As you mention the ideal should be focus on the shortening properly avoiding to tocuh anything else rather than our project, but we are in a kind of "hurry" situation.
I'll check the mapping you propose and see how it behaves and see if it can perform well with the other language mappings.

We are thinking in combine the sling mapping to shorten the URL's and leave the html management to the web server.

I'll try to update the post with any advance in the process.


Best regards