Copied to clipboard

Flag this post as spam?

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

  • Darren Hunter 113 posts 204 karma points
    May 01, 2024 @ 08:57
    Darren Hunter

    Multi Site setup Diffrent 404 Pages

    Hi all,

    I am trying to implement a 404 error pages in a single instance of Umbraco 13 that has multiple sites in it.

    Site A Site B Site C Site ...

    Each of the sites uses there own layout and master page and I like a 404 page for each of the sites.

    I tried the following in the app config.

    "Error404Collection": [ { "Culture": "default", "ContentXPath": "/error-page/" } ]

    Making sure that I have a error-page in each of the sites, this dose not seem to be working.

    Do I need to resort to doing this in code of is there a way in the app settings file to specify a 404 page for each of the sites.

    Thanks Darren

  • Nik 1601 posts 7202 karma points MVP 6x c-trib
    May 01, 2024 @ 11:04

    Hi Darren,

    There is a package that can help with this, it allows you to pick different pages in the content tree to use as your 404, which also allows editors to customise the 404 page as well.

    This would save you modifying config or writing your own code, but it doesn't mean the 404's need to be set via the CMS.



  • Darren Hunter 113 posts 204 karma points
    May 01, 2024 @ 11:45
    Darren Hunter

    I have built a solution:

    Config File: "Redirects": { "Site1": "1093,1753", "Site2": "1203,1754", "Site3": "1303,1755" },

    using Umbraco.Cms.Core.Composing;

    namespace UmbracoCMS.AppCode.404controller { public class RegisterPageNotFoundContentFinderComponent : IComposer { public void Compose(IUmbracoBuilder builder) { builder.SetContentLastChanceFinder

    using Umbraco.Cms.Core.Routing; using Umbraco.Cms.Core.Web;

    namespace UmbracoCMS.AppCode.404controller { public class PageNotFoundContentFinder : IContentLastChanceFinder { private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly IConfiguration _configuration;

        List<ErrorList> _errors;
        public PageNotFoundContentFinder(
                IUmbracoContextAccessor umbracoContextAccessor,
                 IConfiguration configuration)
            _umbracoContextAccessor = umbracoContextAccessor;
            _configuration = configuration;
        public Task<bool> TryFindContent(IPublishedRequestBuilder request)
            _errors = new List<ErrorList>();
            var domainsRedirect = _configuration.GetSection("Redirects");
            var domain = request.Domain;
            var nodeid = domain.ContentId;
            var selectedID = from item in _errors
                             where item.nodeid == nodeid
                             select item.errornodeid;
            var errorNode = selectedID.FirstOrDefault();
            var notFoundPage = _umbracoContextAccessor.GetRequiredUmbracoContext().Content.GetById(errorNode);
            return Task.FromResult(true);
        private void addtoList(string[] item)
            ErrorList _error = new ErrorList();
            _error.nodeid = Int32.Parse(item[0]);
            _error.errornodeid = Int32.Parse(item[1]);
            _errors.Add( _error );


    namespace UmbracoCMS.AppCode.404controller { public class ErrorList { public int nodeid { get; set; } public int errornodeid { get; set; }



    Managed to get this to work.

    A bit of a hack but it works.

  • Kelly 10 posts 90 karma points
    May 06, 2024 @ 18:30

    I have the same question, but I am on Umbraco Cloud and our project uses the Igloo Theme, so we already have a content picker in the settings document type for each site, and we have selected our 404 page.

    However, the theme is only recognizing one of the set 404 pages. I am a beginner and don't know what is causing this not to work out of the box with the theme.

    I have tinkered with the host names so our main site is set to "/" and a sub-site is set to /xx/.

    I tried to add in the appsettings file

    { "Umbraco": { "CMS": { "Content": { "Error404Collection": [ { "Culture": "default", "ContentXPath": xxxxxx" } ] } } } }

    But nothing seemed to work. Is this approach appropriate for use with Igloo theme? I just have to get the right code?

    It becomes difficult as we have 3 environments, so I have to use Xpath and knowing how to define the sites is hard.

Please Sign in or register to post replies

Write your reply to: