Copied to clipboard

Flag this post as spam?

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


  • Gert 81 posts 288 karma points
    Jun 02, 2014 @ 18:41
    Gert
    0

    404 not handled property according to culture

    I have an umbraco site (umbraco v7.1), and I have set up custom 404 handling as per http://our.umbraco.org/Documentation/Using-Umbraco/Config-files/umbracoSettings/index. My content tree is as follows:

    Content
        Root
            Dutch-Homepage
                Dutch-Content
                Dutch-Not-found (id: 1217)
            English-Homepage
                English-Content
                English-Not-found (id: 1218)
    

    And I've set up the

    <error404>
        <errorPage culture="default">1217</errorPage>
        <errorPage culture="nl-BE">1217</errorPage>
        <errorPage culture="en-US">1218</errorPage>
    </error404>
    

    No matter what I try, Umbraco always shows the English node and never the dutch node.

    What am I doing wrong here?

    Thanks and kind regards, Gert

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 03, 2014 @ 21:06
    Jan Skovgaard
    0

    Hi Gert

    Have you setup hostnames for each of the sites in your umbraco solution?

    And have you set the

    /Jan

  • Gert 81 posts 288 karma points
    Jun 04, 2014 @ 11:47
    Gert
    0

    Hi Jan,

    For each of the home pages I have set the language (nl-BE for the default and en-US for the English version). I didn't add any hostnames.

    In the web.config I have set the umbracoHideTopLevelNodeFromPath to false.

    <add key="umbracoHideTopLevelNodeFromPath" value="false"/> 
    

    and off course

    <httpErrors existingResponse="PassThrough"/>
    

    When I enter the url

    mywebsite/nl/pagenotfound
    

    I get the Dutch version, and for the url

    mywebsite/en/pagenotfound
    

    I get the English version, but when I enter the url

    mywbesite/nl/nonexistingpage
    

    I Always get the English PageNotFound page instead of the Dutch one.

    Which setting in de umbracoSettings.config must be set to true?

    Thanks!

    Gert.

  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Jun 04, 2014 @ 13:41
    Richard Soeteman
    0

    Hi Gert and Jan,

    Probably overkill for just 404 set-up. But you might want to check-out SEO Checker http://soetemansoftware.nl/seo-checker You can specify 404 pages per domain and language using a node picker then never worry about it.

    Best,

    Richard

  • Gert 81 posts 288 karma points
    Jun 04, 2014 @ 13:50
    Gert
    0

    Thanks Richard, I read that in some other post ;-), but I suppose this basic functionality must somehow also work out of the box? I am probably missing something.

    Any help is appreciated.

    Thanks! Gert.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 04, 2014 @ 15:51
    Jan Skovgaard
    0

    Hi Gert

    Ok, you probably need to add a hostname for each of your root nodes with the appropriate culture in order for the 404 handling to work I guess. Otherwise I don't see how the 404handler would know about the site culture?

    Sorry about the missing setting in my reply above - The markdown editor sometimes skips what looks like code if it's not properly tagged as code.

    But the setting is <useDomainPrefixes> - But I'm not sure it's required to be set to true in order for the error handling to work but it's a good idea to do it though in order to avoid duplicate content.

    Hope this helps.

    /Jan

  • Gert 81 posts 288 karma points
    Jun 05, 2014 @ 10:18
    Gert
    0

    Hi Jan,

    I'm not using a different domain name for the English site because the top level node is included in the path. So I'm using the same domain.

    I dit set the cultures for both homepage nodes and this works because the dictionary items are translated correctly so this means the system knows the culture.

    Setting <useDomainPrefixes> to true does not work either

    Any other ideas? Thanks!

    Regards, Gert.

  • Amalie Wowern 144 posts 273 karma points MVP c-trib
    Sep 10, 2015 @ 09:03
    Amalie Wowern
    0

    Did you found a solution for this?

  • Gert 81 posts 288 karma points
    Sep 24, 2015 @ 09:10
    Gert
    0

    Hi Amalie,

    I solved this problem by setting the last chance finder of the ContentLastChanceFinderResolver in the ApplicationStarting event. This is the code I'm using:

    public class NotFoundHandler : ApplicationEventHandler
    {
        protected override void ApplicationStarting( UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext )
        {
            base.ApplicationStarting( umbracoApplication, applicationContext );
            ContentLastChanceFinderResolver.Current.SetFinder( new FindNotFound() );
        }
    
        public class FindNotFound : IContentFinder
        {
            public bool TryFindContent( PublishedContentRequest contentRequest )
            {
                //Check if request is a 404
                if ( contentRequest.Is404 )
                {
                    //Get the home node
                    IPublishedContent home = null;
                    var path = contentRequest.Uri.GetAbsolutePathDecoded();
                    var index = path.IndexOf('/', 1);
                    if ( index == -1 )
                    {
                        home = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().First( x => x.DocumentTypeAlias == DocumentTypeAlias.HomePage );
                    }
                    else
                    {
                        var firstPathPart = path.Substring( 0, index );
                        var homePages = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().Where( x => x.DocumentTypeAlias == DocumentTypeAlias.HomePage );
                        foreach ( var page in homePages )
                        {
                            // We assume that the following following parameter is set in the web.config <add key="umbracoHideTopLevelNodeFromPath" value="false"/>  
                            if ( page.Url.StartsWith( firstPathPart ) )
                            {
                                home = page;
                                break;
                            }
                        }
                        if ( home == null )
                        {
                            home = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().First( x => x.DocumentTypeAlias == DocumentTypeAlias.HomePage );
                        }
                    }
    
    
                    //Get the 404 node
                    var notFoundNode = home.Children.Single( x => x.DocumentTypeAlias == DocumentTypeAlias.PageNotFound );
    
                    //Set Response Status to be HTTP 404
                    contentRequest.SetResponseStatus( 404, "404 Page Not Found" );
    
                    //Set the node to be the not found node
                    contentRequest.PublishedContent = notFoundNode;
                }
    
                return true;
            }
        }
    }
    

    I hope this helps.

    Kind regards, Gert.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 24, 2015 @ 09:16
    Dennis Aaen
    2

    Hi Gert,

    Tim Geyssens has also just released a package called Umbraco Page Not Found Manager.

    With this package you can easily manage your sites 404 page(s) from the content context menu.

    https://our.umbraco.org/projects/backoffice-extensions/umbraco-page-not-found-manager/

    Hope this can help other.

    /Dennis

  • Gert 81 posts 288 karma points
    Sep 24, 2015 @ 09:43
    Gert
    0

    Hi Dennis, thanks for letting me know! Kind Regards, Gert.

Please Sign in or register to post replies

Write your reply to:

Draft