0 Replies Latest reply on Jul 28, 2013 11:59 PM by RNI76

    Handling custom (localized) error pages

    RNI76 Level 1

      On our site, we'd like to be able to maintain and serve custom/localized  error pages in the end-users' own language rather than just a standard customized page like /apps/sling/servlet/errorhandler/404.jsp.


      Right now, we're storing these localized pages as /content/<country>/<language>/errors/<errorcode>.html (e.g. /content/be/nl/errors/404.html), allowing editors to maintain them.


      Normally, it wouldn't be hard to find and serve the correct page. You could just serve http://www.mysite.com/content/gb/en/errors/404.html if the users tries to fetch the non-existing page http://www.mysite.com/content/gb/en/invalidpage.html.


      The problem is that we've got an Apache server doing rewriting in front of CQ like this:


      /content/gb/en/products.html -> gb.mysite.com/products.html


      - so when trying to determine which page to serve to the user, we use hard-coded reverse mappings (gb.mysite.com -> /content/gb/en/).


      The thing is, the webmasters need to be able to set up error pages for a new country site without contacting a developer to get the mappings updated.


      But how do I figure out which page to serve without using mappings?


      Ideally, I'd like to use a "site setting" per site, allowing the webmaster to define e.g. /content/gb/en/errors as the "base path" for error pages. But when all I've got to go on is a request for e.g. http://gb.mysite.com/invalid.html, then all I can do is try to find the nearest correct parent that  resolves to a Page - which would then be "/". I thought I could resolve the full path of this root Page to /content/gb/en/, but no luck.


      Any ideas on how to handle this? Any and all suggestions would be most welcome!