Copied to clipboard

Flag this post as spam?

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


  • ianhoughton 281 posts 605 karma points c-trib
    Nov 01, 2017 @ 09:32
    ianhoughton
    0

    Hostnames and urls

    We have a single site with where we have set multiple hostnames on the home node:

    member.site.co.uk

    customer.site.co.uk

    member-test.site.co.uk

    customer-test.site.co.uk

    The issue we have is if you view the site on customer.site.co.uk, some of the navigation is returning the links with member.site.co.uk in the url instead of customer.site.co.uk

    We're creating the navigation using:

    var parent = Model.Content.AncestorOrSelf(2);
    var pages = parent.Children.Where(x => x.IsVisible());
    

    When dubugging the site running on customer.site.co.uk, the Url for Model.Content is member.site.co.uk which happens to be the first Url on the properties tab for the Home node.

    Is this expected behaviour, how can we get it to respect the domain that your viewing the site on?

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Nov 01, 2017 @ 13:24
    Dan Diplo
    0

    Firstly, I wouldn't do this, as you'll then have the same content being served on multiple domains. I'd map only one site and then use redirects in IIS/Web.config to redirect all the other domains to your prefered "canonical" domain.

    But if you are determined, then you can utilise Events in Umbraco You'll need to create a class that inherits from IApplicationEventHandler, as described in the docs. Then you can use the SiteDomainHelper class (in Umbraco.Web.Routing namespace) to register your prefered domain. See at the bottom of https://our.umbraco.org/Documentation/Reference/Routing/Request-Pipeline/outbound-pipeline

    protected override void ApplicationStarting(…)
    {
        SiteDomainHelper.AddSite("default", "customer.site.co.uk");
    }
    
  • ianhoughton 281 posts 605 karma points c-trib
    Nov 01, 2017 @ 14:30
    ianhoughton
    0

    The 2 sites serve different content from a CRM, but the structure and templates are shared.

    I think the issue was that the dev site runs on http and not https, but the hostname was https.

  • John Bergman 483 posts 1132 karma points
    Nov 01, 2017 @ 14:23
    John Bergman
    0

    I'd be curious as to why you would do this, are you wanting to change the behavior between members and customers - if that is the case using member groups would be a better solution?

    Also, why would you have seemingly test instances inside your live umbraco instance?

Please Sign in or register to post replies

Write your reply to:

Draft