There's an OSGI configuration provided by AEM - Apache Sling Resource Resolver Factory for Resource mapping in AEM.
Resource mapping is used to define redirects, vanity URLs and virtual hosts for AEM.
Like when you want to shorten the url (don't want to expose the entire path starting with /content), you can write your entries in URL Mapping property of the above configuration (http://localhost:4502/system/console/configMgr).
For ex. I have my page at http://localhost:4502/content/slingModels63/en.html and I want to slice the middle path of the url, I can have the below mapping and I will be able to access the page by hitting
The URL Mapping also accepts the regex pattern which you can enter for your resource mapping.
But there's a separate mapping location in crxde where you can define mappings for the HTTP protocol - it's /etc/map/http folder as highlighted above in the config.
Here you can create a node of type sling:Mapping and provide your mappings and avoid doing the changes in the OSGI Configuration through Web console.
Use-Case:
If you want to open your pages in aem without .html extension, then create a node of type sling:Mapping and add the two properties with url pattern values to that node - sling:internalRedirect and sling:match as shown below:
Below is the xml snippet of the above node with properties:
<?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/$1.html" sling:match="localhost.4502/content/(.*)$"/>
The above mapping will allow you to access all pages inside content folder to open without .html extension in author instance.
If you want to achieve the same in publish mode, then create /etc/map.publish folder to hold the configurations for the publish environment. These must then be replicated, and the new location (/etc/map.publish) should be configured for the Mapping Location of the Apache Sling Resource Resolver Factory of the publish environment.
Thus, you can define your own regex pattern and mappings upon your requirement and also you can view all your mappings under the JCR ResourceResolver option of the Felix console at http://localhost:4502/system/console/jcrresolver .
Hi Prasanna
ReplyDeleteThis document is very helpful but is it required to configure rewrite rules in dispatcher to access extension less urls then please share the rewrite rules as well.
Thanks
venkat
Have found the extansion url case as per below blog:
ReplyDeletehttps://www.albinsblog.com/2018/04/how-to-implement-extension-less-urls-in-adobe-experience-manager.html#.XzzRzSgzaUk