Sling mapping rewrites URLs of tenants without mapping
Description
Attachments
Activity
Stefan Seifert March 11, 2022 at 4:40 PM
thanks, lgtm! - it's merged

Masoud Rozati November 24, 2021 at 8:00 PM
Is there any chance to review and merge this PR?

Masoud Rozati April 22, 2021 at 9:52 AM
The following solution works fine without generated reverse mapping for root URL
This generates the following mapping tables
Resolver Mappings (URL -> Resource)
Pattern | Replacement | Redirect |
---|---|---|
^https/example.com.443/(.+)$ | /$1, /content/region/site/$1 | internal |
^https/example.com.443/$ | /content/region/site | internal |
^https/example.com.443/ | /content/region/site/ | internal |
Reverse Mapping (Resource Path -> URL)
Pattern | Replacement | Redirect |
---|---|---|
^/content/region/site(.+) | https://example.com/$1 | external: 302 |
^/content/region/site$ | https://example.com/ | external: 302 |
^/content/region/site/ | https://example.com/ | external: 302 |

Masoud Rozati April 9, 2021 at 8:58 AM
unfortunately this solution has also a side effect: non-relevant paths (like dam assets, clientlibs, etc.) are rewritten which results in wrong resource paths.

Masoud Rozati March 24, 2021 at 11:47 AM
I re-open this issue, because the error still exists. I found a new solution that covers the root page mapping too:
https://github.com/wcm-io-devops/conga-aem-definitions/pull/64
This causes the following mapping entries to be generated
resolver mapping
/content/region/site (internal) | |
/content/region/site/ (internal) |
map mapping
^/content/region/site$ | https://example.com/ (external 302) |
^/content/region/site/ | https://example.com/ (external 302) |
For tests I used the /system/console/jcrresolver with these cases:
resolve
URL | expected result |
---|---|
/content/region/site | |
/content/region/site | |
/content/region/site | |
/content/region/site | |
/content/region/site/page1/page2 |
map (reverse mapping)
/content/region/site | |
/content/region/site/page1/page2 |
Details
Details
Assignee
Reporter

Currently the sling mappings generated by aem-definitions for a tenant is like this:
This works fine for the tenant itself. However other tenants that have their own domain but no sling mapping (no URL shortening) get a problem. If a tenant has no sling mapping, all their URLs get rewritten with the last domain in the mapping table. This is because the last entry in the mapping table is the root path "/" which matches to every path. The sling mapper uses in this case the last domain
For example if the page http://myothersite.com/content/myothersite/en.html has a link like this
it's URL is rewritten to http://example.com/content/myothersite/en/contact.html which is obviously the wrong domain
This is specially the case on testing and staging systems where multiple tenants are deployed but not all of them need URL-shortening.
Solutions:
We must not generate any external mappings for the root path.
Following configurations would solve this error. I prefer option 2 because of clearer hierarchy.
Option 1)
Option 2)