etc mapping is not working with core image component | Community
Skip to main content
Level 2
October 17, 2023
Solved

etc mapping is not working with core image component

  • October 17, 2023
  • 1 reply
  • 1365 views

Expected Behaviour
When using the dispatcher module with the associated Resource Resolver Factory rewrite rule, images referenced in /content/wknd should resolve.

Actual Behaviour
Any images in the Image Core Component don't resolve correctly due to rewrite and mapping rules.

The image component maps the path from /content/wkdn/us/en/.... to /us/en/... causing them to return 404 at Apache/Dispatcher as they are not mapping to the page's path in the repository.

 

Please help me on this issue. Thanks!

 

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 EstebanBustamante

Hi, 

 

I recommend reading this article https://blog.3sharecorp.com/shortening-urls-in-aem which explains the behavior you are seeing, this is the default behavior even in the wknd demo site, let me put it simply, the mapper will shorter the image URL as a side effect of shorting the page's URL but the dispatcher module will fix this for the images and will put the whole path back, using something like this: 

Include conf.d/rewrites/default_rewrite.rules # rewrite for root redirect RewriteRule ^/?$ /content/${CONTENT_FOLDER_NAME}/us/en.html [PT,L] RewriteCond %{REQUEST_URI} !^/apps RewriteCond %{REQUEST_URI} !^/bin RewriteCond %{REQUEST_URI} !^/content RewriteCond %{REQUEST_URI} !^/etc RewriteCond %{REQUEST_URI} !^/home RewriteCond %{REQUEST_URI} !^/libs RewriteCond %{REQUEST_URI} !^/saml_login RewriteCond %{REQUEST_URI} !^/system RewriteCond %{REQUEST_URI} !^/tmp RewriteCond %{REQUEST_URI} !^/var RewriteCond %{REQUEST_URI} (.html|.jpe?g|.png|.svg)$ RewriteRule ^/(.*)$ /content/${CONTENT_FOLDER_NAME}/$1 [PT,L]

The reality is that this is not an issue because the mapping should only be enabled on the publisher instance. Since direct access to the publisher is not allowed, your site will be accessed through the dispatcher at the front door. Alternatively, it can be accessed via the author for editing purposes, where this mapping won't occur.

 

Hope this helps!

Hope this helps

1 reply

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
October 17, 2023

Hi, 

 

I recommend reading this article https://blog.3sharecorp.com/shortening-urls-in-aem which explains the behavior you are seeing, this is the default behavior even in the wknd demo site, let me put it simply, the mapper will shorter the image URL as a side effect of shorting the page's URL but the dispatcher module will fix this for the images and will put the whole path back, using something like this: 

Include conf.d/rewrites/default_rewrite.rules # rewrite for root redirect RewriteRule ^/?$ /content/${CONTENT_FOLDER_NAME}/us/en.html [PT,L] RewriteCond %{REQUEST_URI} !^/apps RewriteCond %{REQUEST_URI} !^/bin RewriteCond %{REQUEST_URI} !^/content RewriteCond %{REQUEST_URI} !^/etc RewriteCond %{REQUEST_URI} !^/home RewriteCond %{REQUEST_URI} !^/libs RewriteCond %{REQUEST_URI} !^/saml_login RewriteCond %{REQUEST_URI} !^/system RewriteCond %{REQUEST_URI} !^/tmp RewriteCond %{REQUEST_URI} !^/var RewriteCond %{REQUEST_URI} (.html|.jpe?g|.png|.svg)$ RewriteRule ^/(.*)$ /content/${CONTENT_FOLDER_NAME}/$1 [PT,L]

The reality is that this is not an issue because the mapping should only be enabled on the publisher instance. Since direct access to the publisher is not allowed, your site will be accessed through the dispatcher at the front door. Alternatively, it can be accessed via the author for editing purposes, where this mapping won't occur.

 

Hope this helps!

Hope this helps

Esteban Bustamante