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.
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/.
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:
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!
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.
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
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
Hej Laurence,
I normally use something like this in UrlRewriting.config [root/config/UrlRewriting.config]
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!
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.
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
is working on a reply...