Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arjan H. 226 posts 463 karma points c-trib
    Apr 14, 2023 @ 18:22
    Arjan H.
    0

    Multi-site configuration with multiple host names per root node

    I'm working on a multi-site configuration (not multilingual). The development and staging environments are using the same database. I've assigned multiple host names to the root node of each website, one for development and one for staging, for example:

    Website A

    • websitea.local (dev)
    • websitea.staging.io (staging)

    Website B

    • websiteb.local (dev)
    • websiteb.staging.io (staging)

    When linking between these sites the absolute URL is obviously different based on the environment and this leads to problems because Umbraco doesn't know which host name it should be using to create the absolute URL. Is there an easy way to help Umbraco figure out which absolute URL / host name to use when linking between sites based on the environment it's running on?

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Apr 17, 2023 @ 07:48
    Marc Goodson
    100

    Hi Arjan

    Have a look at ISiteDomainMapper

    https://docs.umbraco.com/umbraco-cms/reference/routing/request-pipeline/outbound-pipeline#site-domain-mapper

    Essentially, Umbraco uses an implementation of this when calculating Urls, it ships with a 'DefaultSiteDomainMapper' that might be all you need to group the URLs of sites together.

      _siteDomainMapper?.AddSite("dev", "websiteb.local", "websiteb.local");
      _siteDomainMapper?.AddSite("staging", "websitea.staging.io", "websiteb.staging.io");
    

    That should mean that when you are 'on websitea.staging.io and there is a link to siteb, it will know to make it via websiteb.staging.io and not the local one.

    But you can create an implementation of ISiteDomainMapper if you need to do something super complex.

    regards

    Marc

  • Arjan H. 226 posts 463 karma points c-trib
    Apr 17, 2023 @ 09:09
    Arjan H.
    0

    Awesome! Sound like this is exactly what I need. I'll check it out.

  • Arjan H. 226 posts 463 karma points c-trib
    Apr 17, 2023 @ 10:01
    Arjan H.
    0

    Works like a charm! Thanks!!!

Please Sign in or register to post replies

Write your reply to:

Draft