Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info

You can reference here for a Site aware exception handling in Magnolia CMS which is updated for Magnolia CMS 5.7.+


The 404 Handler

In some projects you may want to have the possibility to define your own Error-Pages (as 404 etc.).
With magnolia it is either possible to define this pages internally in the website tree, or externally.

...

For this example let's assume that your magnolia site is under /index/
and that you have created your own 404.html error page under that..ie

Code Block

/index/404.html

Edit the magnoliaPublic web.xml (inside webapps\magnoliaPublic\WEB-INF\web.xml)
and add the following section:

Code Block

<error-page>
     <error-code>404</error-code>
     <location>/admintemplates/404.jsp</location>
  </error-page>

Now, create a 404.jsp file inside your \webapps\magnoliaPublic\admintemplates directory
that contains the following jsp code

Code Block

<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
String contextName = request.getContextPath();
String newLocn = contextName + "/index/404.html";
response.setHeader("Location",newLocn);
%>

...