Copied to clipboard

Flag this post as spam?

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


  • Mike Beale 38 posts 132 karma points
    May 23, 2017 @ 14:38
    Mike Beale
    0

    Error pages by hostname

    Hi,

    We have an insallation of Umbraco 7.3.3 which is used for 5 of our smaller websites, each with their own templates & content, setup using different hostnames in Umbraco.

    We want to have different 404 error pages for each site.

    I know about setting the error404 setting in config\umbracoSettings.config as below

    https://our.umbraco.org/Documentation/Reference/Config/umbracoSettings/#errors

    It shows you can have different error pages per culture, but all out sites are en-GB

    Is it possible to set diffenrent error404 pages per hostname?

    Thanks, Mike

  • Craig Mayers 164 posts 508 karma points
    May 23, 2017 @ 19:40
    Craig Mayers
    0

    Hi Mike,

    You could try the following:

    Edit your 'umbracoSettings.config' file.

    <errors>
      <error404>
        <errorPage culture="en-GB">1332</errorPage>
        <errorPage culture="en-US">1332</errorPage>
        <errorPage culture="fr-FR">1185</errorPage>
      </error404>
    </errors>
    

    Set the culture for each errorPage section defined and also the NodeId of the 404 page for each site.

    You will also have to edit your web.config and allow your Umbraco error pages to pass through IIS.

    <httpErrors existingResponse="PassThrough"/>
    

    Let me know how it goes!

    Regards

    Craig

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    May 23, 2017 @ 20:12
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 23, 2017 @ 20:25
    Chriztian Steinmeier
    100

    Hi Mike,

    If you want to dig a little deeper, Anders Bjerner wrote a good post about three different types of error pages over on the 24 Days In Umbraco site...

    Hope that helps,

    /Chriztian

  • Mike Beale 38 posts 132 karma points
    May 24, 2017 @ 13:43
    Mike Beale
    0

    Thanks for your replies.

    @Craig: This is wht the docs say, and is okay with multiple cultures setup, but we have mulitiple sites with the same culture in one instance of Umbraco.

    @David: This looked like an easy solution, but I couldn't get it to work. It would always return the error page for the first site/root node. There is another post with someone else having the same issue with the Page Not Found Manager plugin.

    @Chriztian: Thanks, I managed to get this working.

    First looked at it and it looked a bit over my head! But I got it working, and was pleased, but then noticed that although it was showing the correct 404 page for each site, the http status was 200.

    I fiddled about a bit and found that putting

    contentRequest.SetResponseStatus(404, "404 Page Not Found");
    

    before the final return fixed that.

    So all is looking good now.

    Cheers, Mike

  • Mike Beale 38 posts 132 karma points
    May 25, 2017 @ 10:43
    Mike Beale
    0

    Just found this is causing a problem with pages with an alternate URL with umbracoUrlAlias

    When you browse to the umbracoUrlAlias URL they all return 404 errors, if I disable the code then the umbracoUrlAlias work again.

    Browsing using the full URL works, just when using the alternate url.

Please Sign in or register to post replies

Write your reply to:

Draft