[JIRA] (WDCONGA-21) Sling mapping rewrites URLs of tenants without mapping

95 views
Skip to first unread message

Masoud Rozati (JIRA)

unread,
Mar 12, 2019, 7:34:24 AM3/12/19
to wcm-i...@googlegroups.com
Masoud Rozati created WDCONGA-21:
------------------------------------

Summary: Sling mapping rewrites URLs of tenants without mapping
Key: WDCONGA-21
URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
Project: wcm.io DevOps CONGA
Issue Type: Bug
Components: AEM Definitions
Reporter: Masoud Rozati
Attachments: sling-root-mapping.png

Currently the sling mappings generated by aem-definitions for a tenant is like this:
{code}
/etc/map/https
+- example.com
@sling:internalRedirect=["/","/content/region/site"]
{code}
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
!sling-root-mapping.png!

For example if the page http://mysite.com/content/mysite/en.html has a link like this
{code}<a href="/content/mysite/en/contact.html">Contact us</a>{code}
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)*
{code}
/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/(.*)"]
{code}

*Option 2)*
{code}
/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/(.*)"]
{code}





--
This message was sent by Atlassian Jira
(v1001.0.0-SNAPSHOT#100099)

Masoud Rozati (JIRA)

unread,
Mar 12, 2019, 7:35:23 AM3/12/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Masoud Rozati updated WDCONGA-21:
---------------------------------
Description:
Currently the sling mappings generated by aem-definitions for a tenant is like this:
{code}
/etc/map/https
+- example.com
@sling:internalRedirect=["/","/content/region/site"]
{code}
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
!sling-root-mapping.png!

For example if the page http://myothersite.com/content/myothersite/en.html has a link like this
{code}<a href="/content/myothersite/en/contact.html">Contact us</a>{code}
was:
> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Attachments: sling-root-mapping.png
>
>
> Currently the sling mappings generated by aem-definitions for a tenant is like this:
> {code}
> /etc/map/https
> +- example.com
> @sling:internalRedirect=["/","/content/region/site"]
> {code}
> 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
> !sling-root-mapping.png!
> For example if the page http://myothersite.com/content/myothersite/en.html has a link like this
> {code}<a href="/content/myothersite/en/contact.html">Contact us</a>{code}

Masoud Rozati (JIRA)

unread,
Mar 12, 2019, 9:26:07 AM3/12/19
to wcm-i...@googlegroups.com

Stefan Seifert (JIRA)

unread,
Mar 12, 2019, 6:14:46 PM3/12/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert reassigned WDCONGA-21:
-------------------------------------

Assignee: Tobias Richter
Sprint: (was: )
Fix Version/s: CONGA AEM Definitions 1.4.6

looks basically good to me, but i've not tested it yet.

[~trichter] can you have a look as well? can you give it a test run?

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Tobias Richter
> Fix For: CONGA AEM Definitions 1.4.6

Tobias Richter (JIRA)

unread,
Mar 13, 2019, 11:49:51 AM3/13/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20798#comment-20798 ]

Tobias Richter commented on WDCONGA-21:
---------------------------------------

Is there an existing deadline for this issue?

Masoud Rozati (JIRA)

unread,
Mar 13, 2019, 1:07:54 PM3/13/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20799#comment-20799 ]

Masoud Rozati commented on WDCONGA-21:
--------------------------------------

not from my side

Stefan Seifert (JIRA)

unread,
Mar 13, 2019, 1:25:46 PM3/13/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20800#comment-20800 ]

Stefan Seifert commented on WDCONGA-21:
---------------------------------------

should be part of the next aem-definitions release, we have not a fixed date for it yet. by end of march would bee good.

Tobias Richter (JIRA)

unread,
Mar 15, 2019, 3:16:05 PM3/15/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tobias Richter reassigned WDCONGA-21:
-------------------------------------

Assignee: Masoud Rozati (was: Tobias Richter)

[~mrozati] sorry, but i can not reproduce the issue so i am not able to verify the fix.
Please get in touch with me next week in order to solve this.

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Masoud Rozati

Tobias Richter (JIRA)

unread,
Mar 18, 2019, 9:56:58 AM3/18/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tobias Richter reassigned WDCONGA-21:
-------------------------------------

Assignee: Tobias Richter (was: Masoud Rozati)

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Tobias Richter

Tobias Richter (JIRA)

unread,
Mar 18, 2019, 9:58:09 AM3/18/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tobias Richter reassigned WDCONGA-21:
-------------------------------------

Assignee: Stefan Seifert (was: Tobias Richter)

[~sseifert] I just had a short screensession with [~mrozati] and i was now able to reproduce the issue and the solution.
I am not a sling mapping expert but for me the solution looks good.

[~mrozati] can you please update your PR and resolve the existing conflicts?

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Stefan Seifert

Stefan Seifert (JIRA)

unread,
Mar 19, 2019, 7:18:22 AM3/19/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert resolved WDCONGA-21.
-----------------------------------
Resolution: Fixed

thanks, it's merged

Tobias Richter (JIRA)

unread,
Mar 19, 2019, 11:30:39 AM3/19/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tobias Richter reopened WDCONGA-21:
-----------------------------------
Assignee: Masoud Rozati (was: Stefan Seifert)

As diskussed the PR
https://github.com/wcm-io-devops/conga-aem-definitions/pull/40

will be reverted with:
https://github.com/wcm-io-devops/conga-aem-definitions/pull/46

The additional PR https://github.com/wcm-io-devops/conga-aem-definitions/pull/45 was closed.

There were unforeseen side-effects with css and js artifacts where the URL was not adjusted from "/content/pro-vision/sample/de.js_config.js" to "de.js_config.js".

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Masoud Rozati

Stefan Seifert (JIRA)

unread,
Mar 19, 2019, 12:42:28 PM3/19/19
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert updated WDCONGA-21:
----------------------------------
Sprint: (was: )
Fix Version/s: (was: CONGA AEM Definitions 1.4.6)

ok, taking this out of the next release for the moment

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Masoud Rozati

Masoud Rozati (JIRA)

unread,
Jan 29, 2020, 9:16:43 AM1/29/20
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Masoud Rozati closed WDCONGA-21.
--------------------------------
Resolution: Won't Fix
(v1001.0.0-SNAPSHOT#100118)

Masoud Rozati (JIRA)

unread,
Mar 24, 2021, 7:47:07 AM3/24/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Masoud Rozati reopened WDCONGA-21:
----------------------------------
Assignee: Stefan Seifert (was: Masoud Rozati)

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

{noformat}
/etc/map/https
+- example.com
| | @sling:internalRedirect = ["/content/region/site"]
| |
| +- rootpath-reverse-mapping
| | @sling:match = "$"
| | @sling:internalRedirect = ["/content/region/site"]
{noformat}

This causes the following mapping entries to be generated
*resolver mapping*
|^https://example.com/$ | /content/region/site (internal)|
|^https://example.com/ | /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 ||
| https://example.com | /content/region/site |
| https://example.com/ | /content/region/site |
| https://example.com/.html | /content/region/site |
| https://example.com/.selector.json | /content/region/site |
| https://example.com/page1/page2.html | /content/region/site/page1/page2 |

*map* (reverse mapping)
| /content/region/site | https://example.com/ |
| /content/region/site/page1/page2 | https://example.com/page1/page2 |


> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Stefan Seifert
(v1001.0.0-SNAPSHOT#100156)

Masoud Rozati (JIRA)

unread,
Mar 24, 2021, 8:01:31 AM3/24/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Masoud Rozati reassigned WDCONGA-21:
------------------------------------

Assignee: Masoud Rozati (was: Stefan Seifert)

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Masoud Rozati

Masoud Rozati (JIRA)

unread,
Apr 9, 2021, 4:58:03 AM4/9/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21291#comment-21291 ]

Masoud Rozati commented on WDCONGA-21:
--------------------------------------

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 (JIRA)

unread,
Apr 22, 2021, 5:40:20 AM4/22/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Masoud Rozati reassigned WDCONGA-21:
------------------------------------

Assignee: Unassigned (was: Unassigned)

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
(v1001.0.0-SNAPSHOT#100157)

Masoud Rozati (JIRA)

unread,
Apr 22, 2021, 5:52:58 AM4/22/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21297#comment-21297 ]

Masoud Rozati commented on WDCONGA-21:
--------------------------------------

The following solution works fine without generated reverse mapping for root URL

{noformat}/etc/map/https
+- example.com
| | @sling:internalRedirect = ["/content/region/site"]
| |
| +- resolver-mapping
| | @sling:match = "(.+)$"
| | @sling:internalRedirect = ["/$1","/content/region/site/$1"]
| |
| +- reverse-mapping-root-with-selector
| | @sling:match = "$1"
| | @sling:internalRedirect = ["/content/region/site(\\..+)"]
| |
| +- reverse-mapping-root
| | @sling:match = "$"
| | @sling:internalRedirect = ["/content/region/site"]{noformat}

[https://github.com/wcm-io-devops/conga-aem-definitions/pull/64|https://github.com/wcm-io-devops/conga-aem-definitions/pull/64|smart-link]

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 (JIRA)

unread,
Nov 24, 2021, 3:00:34 PM11/24/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21389#comment-21389 ]

Masoud Rozati commented on WDCONGA-21:
--------------------------------------

Is there any chance to review and merge this PR?
(v1001.0.0-SNAPSHOT#100183)

Stefan Seifert (JIRA)

unread,
Mar 11, 2022, 11:22:42 AM3/11/22
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert reassigned WDCONGA-21:
-------------------------------------

Assignee: Stefan Seifert (was: Unassigned)

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Stefan Seifert
(v1001.0.0-SNAPSHOT#100197)

Stefan Seifert (JIRA)

unread,
Mar 11, 2022, 11:40:38 AM3/11/22
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WDCONGA-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert resolved WDCONGA-21.
-----------------------------------
Fix versions: CONGA AEM Definitions 1.12.0
Resolution: Fixed

thanks, lgtm! - it's merged

> Sling mapping rewrites URLs of tenants without mapping
> ------------------------------------------------------
>
> Key: WDCONGA-21
> URL: https://wcm-io.atlassian.net/browse/WDCONGA-21
> Project: wcm.io DevOps CONGA
> Issue Type: Bug
> Components: AEM Definitions
> Reporter: Masoud Rozati
> Assignee: Stefan Seifert
> Fix For: CONGA AEM Definitions 1.12.0
Reply all
Reply to author
Forward
0 new messages