Copied to clipboard

Flag this post as spam?

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


  • djscorch 67 posts 106 karma points
    Apr 18, 2012 @ 11:54
    djscorch
    0

    Do the Multi Lingual 404 pages work in 4.7.1?

    Am I being naive thinking that all I need to do is set the host names and add the following to umbracoSettings.config?

     

    <errors>
    <error404>
            <errorPage culture="default">1141</errorPage>
    <errorPage culture="en-GB">3806</errorPage>
            <errorPage culture="de-DE">3806</errorPage>        
    </error404>
    </errors>

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    Apr 18, 2012 @ 14:17
    Mike Chambers
    0

    I've had success with

     

     

    <error404>
    <errorPage domain="default">5432</errorPage>
    <errorPage domain="en.domain.com">5432</errorPage>
    <errorPage domain="de.domain.com">3831</errorPage>
    </error404>

    don't forget to also set

     

    <requestHandler>
    <!-- this will ensure that urls are unique when running with multiple root nodes -->
    <useDomainPrefixes>true</useDomainPrefixes>

     

    But saying that... I've not successfully got it to work not when using medium trust and <add key="umbracoUseDirectoryUrls" value="true" />

    I had to add my own 404 handler to mimic what the inbuilt one should be doing...

     public class FidusCMS404Redirect : INotFoundHandler
        {
            private int _redirectID = -1;
    
            #region INotFoundHandler Members
    
            public bool CacheUrl
            {
                get
                {
                    return false;
                }
            }
    
            public bool Execute(string url)
            {
    
                if (umbraco.UmbracoSettings.UseDomainPrefixes)
                {
                    // we have multiple domains, try and map 404's
                    XmlNode error404Node = UmbracoSettings.GetKeyAsNode("/settings/content/errors/error404");
    
    
                    if (error404Node.ChildNodes.Count > 0 && error404Node.ChildNodes[0].HasChildNodes)
                    {
                        // try to get the 404 based on current domain
                        XmlNode domainErrorNode;
                        string CurrentDomain = System.Web.HttpContext.Current.Request.Url.Host.ToLower();
    
                        // try match to domain
                        domainErrorNode = error404Node.SelectSingleNode(String.Format("errorPage [@domain = '{0}']", CurrentDomain));
    
                        try
                        {
                            _redirectID = int.Parse(domainErrorNode.FirstChild.Value);
                        }
                        catch
                        {
                            domainErrorNode = error404Node.SelectSingleNode(String.Format("errorPage [@domain = '{0}']", "default"));
    
                            try
                            {
                                _redirectID = int.Parse(domainErrorNode.FirstChild.Value);
                            }
                            catch
                            {
                                _redirectID = Convert.ToInt32(UmbracoSettings.GetKey("/settings/content/errors/error404"));
                            }
                        }
    
                    }
                    else
                    {
                        _redirectID = Convert.ToInt32(UmbracoSettings.GetKey("/settings/content/errors/error404"));
                    }
    
                }else{
                    _redirectID = Convert.ToInt32(umbraco.UmbracoSettings.GetKey("/settings/content/errors/error404"));
                }            
    
                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.NotFound, _redirectID, "404 Redirect - " + HttpContext.Current.Request.Url);
                //301 rather than just 404
                //HttpContext.Current.Response.Status = "301 Moved Permanently";
                //HttpContext.Current.Response.AddHeader("Location", umbraco.library.NiceUrl(_redirectID));
    
                return true;
            }
    
            public int redirectID
            {
                get
                {
                    //return 1983;
                    return _redirectID;
                }
            }
    
            #endregion
        }

     

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    Apr 18, 2012 @ 14:19
    Mike Chambers
    0

    Forgot to add that the 404 custom implementation here, assumes only one primary domain for each root node (which is good seo anyways :-))

  • djscorch 67 posts 106 karma points
    Apr 18, 2012 @ 16:31
    djscorch
    0

    I have <add key="umbracoUseDirectoryUrls" value="true" />

    and <useDomainPrefixes>false</useDomainPrefixes>

    As i'm using 'fake' domains like /de/

    Although i've set the culture on the home nodes...

  • Mike Chambers 636 posts 1253 karma points c-trib
    Apr 18, 2012 @ 16:56
    Mike Chambers
    0

    no worries... I've not tried with the culture settings on the subdirectory approach for multilanguage.

  • nicolas ruiz 74 posts 95 karma points
    Jun 26, 2012 @ 15:51
    nicolas ruiz
    0

    Hey djscorch,

    How did you finally manage to make it work ?

    Thanks,

    Nicolas.

Please Sign in or register to post replies

Write your reply to:

Draft