Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

etc mapping is not working with core image component

Avatar

Level 2

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!

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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