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!
Solved! Go to Solution.
Views
Replies
Total Likes
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
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
Views
Likes
Replies
Views
Likes
Replies