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.
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.
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.
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
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;
}
}
}
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:
And I've set up the
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
Hi Gert
Have you setup hostnames for each of the sites in your umbraco solution?
And have you set the
/Jan
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.
and off course
When I enter the url
I get the Dutch version, and for the url
I get the English version, but when I enter the url
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.
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
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.
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
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 eitherAny other ideas? Thanks!
Regards, Gert.
Did you found a solution for this?
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:
I hope this helps.
Kind regards, Gert.
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
Hi Dennis, thanks for letting me know! Kind Regards, Gert.
is working on a reply...