JCR Resource Resolver mappings with regex(removing parts of url in a certain way) | Community
Skip to main content
Peter_Puzanovs
Community Advisor
Community Advisor
October 16, 2015
Solved

JCR Resource Resolver mappings with regex(removing parts of url in a certain way)

  • October 16, 2015
  • 4 replies
  • 3982 views

Trying to configure JCR Resource resolve in a certain way:

Given requirement:

Where article has path /content/company/en/articles/some/article should be resolved as /some/article

Tried to use this Url Mappings rule (resource.resolver.mapping):

/content/company/en/articles/(.*):/$1

This works in the system console and places like sitemap.xml where ResourceResolver.map is invoked.

However, when trying to open the actual page, following error is returned:

No resource found

Cannot serve request to /some/article.html on this server


 

What is wrong with current configuration ?

 

Thanks,

Peter

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

Found that it is possible to solve without the use of regex, simply put /content/company/en/articles/:/ this will resolve everything that starts with articles/ to the root /

4 replies

smacdonald2008
Level 10
October 16, 2015

Cross check your mapping with the information in this Sling topic:

https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html

smacdonald2008
Level 10
October 16, 2015

Here is a good community article that may help:

http://aem.matelli.org/url-mapping-and-deep-linking/

Peter_Puzanovs
Community Advisor
Community Advisor
October 16, 2015

Thank you for your reply Scott.

Have already read through the sling docs page and url mapping and deep linking.

These articles do not tend to give answer to my particular problem since they both focus on mappings through /etc/map which I am not allowed to use due to some business requirement. All the mappings need to be done through OSGi console. After adding mapping regex in OSGi console 404 error is returned when page is opened.

How should I setup regex for it to work in the OSGi console(given the example described before) ?

Thanks,

Peter

Peter_Puzanovs
Community Advisor
Peter_PuzanovsCommunity AdvisorAuthorAccepted solution
Community Advisor
October 16, 2015

Found that it is possible to solve without the use of regex, simply put /content/company/en/articles/:/ this will resolve everything that starts with articles/ to the root /