Sling mapping rewrites URLs of tenants without mapping

Description

Currently the sling mappings generated by aem-definitions for a tenant is like this:

1 2 3 /etc/map/https +- example.com @sling:internalRedirect=["/","/content/region/site"]

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

1 <a href="/content/myothersite/en/contact.html">Contact us</a>

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)

1 2 3 4 5 6 7 /etc/map/https +- example.com | @sling:match = "example.com/(.*)" | @sling:internalRedirect = ["/$1","/content/region/site/$1"] +- example.com_reverse | @sling:match = "example.com/$1" | @sling:internalRedirect = ["/content/region/site/(.*)"]

Option 2)

1 2 3 4 5 6 7 8 9 10 11 /etc/map/https +- example.com | | @sling:internalRedirect = ["/content/region/site"] | | | +- content-mapping | | @sling:match = "(.+)$" | | @sling:internalRedirect = ["/$1","/content/region/site/$1"] | | | +- reverse-content-mapping | | @sling:match = "$1" | | @sling:internalRedirect = ["/content/region/site/(.*)"]

Environment

None

Status

Assignee

Masoud Rozati

Reporter

Masoud Rozati

Labels

None

Components

Priority

Major
Configure