Hi all,
I am using image v3 component (aem core components v2.19.2) and created a custom image component based on the same. The OOTB AdaptiveImageServlet is loading the image renditions in the below URL format,
Author:
/content/<project_path>/<page_path>/<component_path>/<component_name>.coreimg.<quality>.<width>.<extension>/<timestamp>/<filename>.<extension>
Publish:
/content/<project_path>/<page_path>/<component_path>/<component_name>.coreimg.<quality>.<width>.<extension>/<timestamp>/<filename>.<extension>
Because of the above implementation and the website sling mapping to shorten the URLs, the image paths are also shortened. So the images are not being displayed in publisher. The images are not accessible with the same URL format from the dispatcher as well which is a different issue altogether.
But is there a way to exclude the images from being picked up by the sling mappings so that the complete URLs are available in publisher and the same can be accessed by dispatcher as well.
Tried various regex patterns for sling:match but no luck. Completely blocked with this issue. Any help would be appreciated.
Solved! Go to Solution.
Views
Replies
Total Likes
You should be able to handle this through the dispatcher PT rewrite rule; even though the URL is shortened from the publisher, the dispatcher can always send the complete path through the PT rule.
My assumption is you are following the latest dispatcher configuration structure; below is the sample PT rule configured on the rewrite file(additional conditions can be added based on the need)
RewriteCond %{REQUEST_URI} !^/apps/(.*) [NC]
RewriteCond %{REQUEST_URI} !^/etc(.*) [NC]
RewriteCond %{REQUEST_URI} !^/home/(.*) [NC]
RewriteCond %{REQUEST_URI} !^/libs(.*) [NC]
RewriteCond %{REQUEST_URI} !^/content(.*) [NC]
RewriteCond %{REQUEST_URI} !^/system(.*) [NC]
RewriteCond %{REQUEST_URI} !^/dam(.*) [NC]
RewriteCond %{REQUEST_URI} !^/robots.txt [NC]
RewriteCond %{REQUEST_URI} !^/(.*)/sitemap.xml [NC]
RewriteRule ^/(.*) /content/test/$1 [PT]
Regards
Albin
Hi,
Can you share the Sling mapping here?
You can do the following:
You can restrict sling mappings with .html extension for apply only for page.
or
Apache rewrite rules can also be written on the dispatcher for assets to resolve on AEM Publish.
Please find the sling mapping used below,
"map": {
"jcr:primaryType": "sling:Mapping",
"jcr:createdBy": "admin",
"jcr:created": "Sun Feb 05 2023 14:40:30 GMT+0000",
"sling:match": "$1",
"sling:internalRedirect": "/content/we-retail/us/en/(.+)"
},
"mapWithoutHtml": {
"jcr:primaryType": "sling:Mapping",
"jcr:createdBy": "admin",
"jcr:created": "Sun Feb 05 2023 16:50:26 GMT+0000",
"sling:match": "$1",
"sling:internalRedirect": "/content/we-retail/us/en/(.+)\.html"
},
"mapHomePage": {
"jcr:primaryType": "sling:Mapping",
"jcr:createdBy": "admin",
"jcr:created": "Sun Feb 05 2023 16:50:26 GMT+0000",
"sling:match": "$",
"sling:internalRedirect": "/content/we-retail/us/en(\.html)?"
}
Both the solution we actually tried but no luck with the regex patterns or the proper rewrite conditions as well. Could you please help me with the correct sling match or the rewrite condition if possible.
I would suggest to put this redirect at apache as mentioned by @Albin_Issac
For sling mappings, you can check the below documents
https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html
You should be able to handle this through the dispatcher PT rewrite rule; even though the URL is shortened from the publisher, the dispatcher can always send the complete path through the PT rule.
My assumption is you are following the latest dispatcher configuration structure; below is the sample PT rule configured on the rewrite file(additional conditions can be added based on the need)
RewriteCond %{REQUEST_URI} !^/apps/(.*) [NC]
RewriteCond %{REQUEST_URI} !^/etc(.*) [NC]
RewriteCond %{REQUEST_URI} !^/home/(.*) [NC]
RewriteCond %{REQUEST_URI} !^/libs(.*) [NC]
RewriteCond %{REQUEST_URI} !^/content(.*) [NC]
RewriteCond %{REQUEST_URI} !^/system(.*) [NC]
RewriteCond %{REQUEST_URI} !^/dam(.*) [NC]
RewriteCond %{REQUEST_URI} !^/robots.txt [NC]
RewriteCond %{REQUEST_URI} !^/(.*)/sitemap.xml [NC]
RewriteRule ^/(.*) /content/test/$1 [PT]
Regards
Albin
Hi @Albin_Issac ,
Thanks for the reply and we have fixed in kind of similar ways now. Please find the dispatcher PT rewrite rule fix below,
# Rewrite image calls
RewriteCond %{REQUEST_URI} !^/content/experience-fragments
RewriteCond %{REQUEST_URI} !^/content/dam
RewriteCond %{REQUEST_URI} (.jpeg|.png|.svg|.jpg|.gif)$
RewriteRule ^/(.*)$ $aempath/home/$1 [PT,L]
Views
Likes
Replies
Views
Likes
Replies