Expand my Community achievements bar.

SOLVED

Resource Resolver Mapping Same Path to Different Domains

Avatar

Level 3

Hi Everyone,

 

We have a requirement where we need to create Resource Resolver mapping or other solution that will helps us get the appropriate shorten url for the same content when accessed through different subdomains. For example:

We have a content path /content/mysite/mypage.html

 

And we have 2 domains abc.mysite.com and xyz.mysite.com. mypage.html contains links to other internal resources(pages etc.). Our components use ResourceResolve.map() to create the necessary absolute shorten URL.

We have created a mapping in /etc/map for both abc.mysite.com and xyz.mysite.com like this:

--https

    abc.mysite.com

           content

               sling:internalRedirect:/content/mysite/

 

  

   xyz.mysite.com

           content

               sling:internalRedirect:/content/mysite/

 

This works fine for abc.mysite.com but not for xyz.mysite.com. In other words if we access abc.mysite.com we get the internal page and the links to other pages on it are https://abc.mysite.com/.... but if we access the page from xyz.mysite.com again the links on it are https://abc.mysite.com/.... 

From what I understand since there are 2 mappings for the same path (/content/mysite/) the mapping naturally picks the first one (for abc.) and ignores the second one. How can we achieve the necessary result, which would be to have links on a page accessed through one subdomain have the same subdomain. I know we can alter the links in the backend but we were looking for a solution via /etc/map.

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi @bobbym33667819 

Have you explored using Apache Rewrite Rules to achieve subdomain-specific URL mappings.

In your Apache configuration, create rewrite rules specific to each subdomain. These rules will map incoming requests to the appropriate content path.
Example (in Apache's configuration file):

 

RewriteCond %{HTTP_HOST} ^abc\.mysite\.com$ [NC]
RewriteRule ^(.*)$ /content/mysite$1 [PT,L]

RewriteCond %{HTTP_HOST} ^xyz\.mysite\.com$ [NC]
RewriteRule ^(.*)$ /content/mysite$1 [PT,L]



These rules will redirect requests from abc.mysite.com to /content/mysite, and similarly for xyz.mysite.com.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Hi @bobbym33667819 

Have you explored using Apache Rewrite Rules to achieve subdomain-specific URL mappings.

In your Apache configuration, create rewrite rules specific to each subdomain. These rules will map incoming requests to the appropriate content path.
Example (in Apache's configuration file):

 

RewriteCond %{HTTP_HOST} ^abc\.mysite\.com$ [NC]
RewriteRule ^(.*)$ /content/mysite$1 [PT,L]

RewriteCond %{HTTP_HOST} ^xyz\.mysite\.com$ [NC]
RewriteRule ^(.*)$ /content/mysite$1 [PT,L]



These rules will redirect requests from abc.mysite.com to /content/mysite, and similarly for xyz.mysite.com.