Copied to clipboard

Flag this post as spam?

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


  • Laurence Gillian 600 posts 1219 karma points
    Jul 02, 2012 @ 18:51
    Laurence Gillian
    1

    Umbraco and IIS7 - Custom Errors

    Hello,

    After a bit of trawling the internet and the forums, it would appear there is a problem/confusion as to setting up Umbraco 4.7.2 with CustomErrors in IIS7+.

    The problem is, in a default IIS setup errors are not 'passed' into Umbraco.

    It is possible to force Umbraco to handle the errors, but this requires a configuration change to httpErrors, that disables the default custom errors behavior. This can be apporached using the following technique.

    http://mytechlifedays.wordpress.com/2012/03/15/custom-error-page-not-working-in-umbraco-4-7/

    When this is set, however, this won't actually forward across all errors, and it's been recommended in other threads and on stackoverflow that enabling the 'detailed' errors will resolve this issue. This does go some way to resolving the problem, but in some situations will lead to a traditional IIS detailed error page being displayed, if the requested URL is not processed by Umbraco/ISAPI. This is not good! And defeats the purpose of customErrors! 

    -

    So, what's the solution to have customErrors for Umbraco 4.7.2 running on IIS7+.

    The above solutions only support .aspx pages, and do not support say a .jpg being hit. 

    -

    The use case of this is, I am using the 301 redirects package. I've got a site, which has 1 to 1 mappings, from an old Joomla install, into a nice shiny Umbraco install. I'd like to capture a URL such as /index.php?id=2000 and make it hit /en/. 

    This our thead, has a similar requirement, but to no avail.

    There must be a nice way of doing this,

    Just spent aaaaages working out, why the Umbraco 404 handlers wasn't catching anything >.<

    Laurence 

  • Laurence Gillian 600 posts 1219 karma points
    Jul 02, 2012 @ 19:08
    Laurence Gillian
    0

    So to clarify.

    1. Best practices for getting Umbraco to handle those Errors

    2. Get Umbraco to handle none .aspx errors. e.g. missing .jpg, etc

  • Anders Stentebjerg 58 posts 234 karma points
    Jul 03, 2012 @ 08:54
    Anders Stentebjerg
    0

    Hej Laurence,

    I normally use something like this in UrlRewriting.config [root/config/UrlRewriting.config]

    <add name="redirectAll" redirect="Domain" ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite" virtualUrl="http://mydomain.com/(.*)" redirectMode="Permanent" destinationUrl="http://www.mydomain.com" />
  • Funka! 398 posts 661 karma points
    Jul 03, 2012 @ 21:58
    Funka!
    0

    Here is one very simple approach to this, maye will give you idea on how to customize for your needs:

    If you just want a simple content a.k.a. textPage to show up when you get a 404, go ahead and create a regular ol' page in your site. Call it "/404-not-found/" (or "/404-not-found.aspx" if your site isn't using pretty URLs) or whatever you want really. (Don't call it just /404/ since there is a bug with purely numerical paths being browsed from the root like this.) Be sure to add a macro to this page to set the Response.Status to 404 Not Found, so that search engines are happy.

    Then, in your web.config file, under system.webServer, you can set the following:

    <httpErrors>
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" prefixLanguageFilePath="" path="/404-not-found/" responseMode="ExecuteURL" />
    </httpErrors>

    This is just for the 404 but you could theoretically do this for your other statuses. You do not even need to change the error404 setting in the umbracoSettings.config file. IIS will try to handle the 404 itself and just send them to the page you indicated. Then take it from there!

    Good luck!

  • Laurence Gillian 600 posts 1219 karma points
    Jul 05, 2012 @ 13:57
    Laurence Gillian
    0

    Thank you for the replys, with response to the second part of the question (PHP), I've taken Anders idea and written this as a URL rewrite rule that lives in the web.config. This just prefixes PHP pages, with an .aspx, which means the file gets to Umbraco. 

    <rule name="PHP" stopProcessing="true">
    <match url="(.*).php(/?.*)*$" />
    <action type="Rewrite" url="/301.aspx/{R:0}/" appendQueryString="true" />
    </rule>

    This is lovely and I can now use the 301 redirects package to handle remapping these old Joomla urls.

    -

    The first part of my question, I had made an error in my web.config.

    The required setup is.

    <system.web>
     <customErrors mode="On" />

    <system.webServer>
      <httpErrors existingResponse="PassThrough" />

    -

    My next question - is it possible to delivery a catch-all error page? 

    Double thanks! Laurie

Please Sign in or register to post replies

Write your reply to:

Draft