How to setup strict domain handling in a multisite installation?

I’ve got an Umbraco Cloud environment that hosts multiple websites. I’m trying to find a way to prevent Umbraco finding content for a request that doesn’t match the domain configured on the root node.

For example, I have two sites configured with domain1.com and domain2.com respectively. Right now, if someone browses to the default project-name.uksouth01.umbraco.io domain. Umbraco will serve the first root node it finds, even if it isn’t configured with that domain name.

I found that there used to be a setting for this called useDomainPrefixes which may have been replaced with the following.

"Umbraco": {
    "CMS": {
        "WebRouting": {
            "UrlProviderMode": "Absolute",
        },
    }
}

But it seems this only works for the URLS displayed in the Backoffice content info screen and doesn’t affect routing.

Anyone have a solution for this or can point me to the right customisation point? It feels like the documentation isn’t quite up to date with V15 changes.

1 Like

I turned on debug logging and looked at the code, seems like the UrlProviderMode setting doesn’t get checked during routing and the IContentFinder implementation makes use of IDocumentUrlService which in turn doesn’t check this setting either.

The IDocumentUrlService falls back to finding the first root content node inside a private method.

I consider this behaviour as a bug, so I’ve raised issue #19010

Hmm, never thought of that. Our root nodes don’t have templates (because they are usually containers), so it will just cause a 404, but it DOES try to server the first root node it finds. This has been the behaviour as long as I can remember.

The UrlProviderMode is for how urls are generated, but how routing is handled as far as I know.

Not sure if I should consider this a bug, but behaviour that was intended like this. But a setting where you can disable serving content when the domain is not mapped in any cultures and hostnames would be nice I guess :slight_smile: Well see about your bug report, maybe it will be moved to discussions.

I think you probably need to check out the HideTopLevelNodeFromPath setting:

From skimming your posts it does seem like expected behavior.

Thanks for the info Sebastiaan.
According to that page the setting is enabled by default, should this be disabled then for my scenario?

Thats a shame, maybe I can use your method of containers in the root as a workaround?

I’ve changed this behaviour before by replacing the default IContentFinder to only return content if the request is for a valid domain.

I can’t find the exact code that I used, but I think simply replacing line 64 here might be enough:

Something like this?

if (frequest.Domain != null)
{
    route = frequest.Domain.ContentId +
            DomainUtilities.PathRelativeToDomain(frequest.Domain.Uri, frequest.AbsolutePathDecoded);
}
else
{
    return Task.FromResult(false);
}
1 Like

Thanks Jason

I’ll give this a try and see if it’ll work for me.