Is it possible customizing error pages under my project (not directly under apps) ? | Community
Skip to main content
Level 3
July 11, 2022
Solved

Is it possible customizing error pages under my project (not directly under apps) ?

  • July 11, 2022
  • 3 replies
  • 886 views

Dear community,

 

I've checked that error pages can be customized by creating the sling/servlet/errorhandler/error-type.jsp.

However, I'd like to customize the error page only for my project that is stored under "apps/my_region/my_project". (There are other projects under my_region and have their own error pages)

 

As expected, it doesn't work when I moved the sling/... folder under my_project. Would like to know if there is any approach to customize the error page for the project.

 

Thanks in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mohit_KBansal

Considering your use case, you should handle error processing at the apache level. 

 

What does it mean?

AEM returns standard error page (consider it as a very lightweight error page response). Idea is to keep error processing very light weight on AEM.

 

How should error handle work?

Create an error page in AEM like other pages of your site.

/content/path/to/your/site/home/errors/404.html
/content/path/to/your/site/home/errors/500.html

Error response should be handed at the apache level. In your virtual host configuration, add a Document with the path of AEM page. 

ErrorDocument 404 /content/path/to/your/site/home/errors/404.html 
ErrorDocument 401 /content/path/to/your/site/home/errors/500.html

 

How error processing will work?

  1. When a user hit a random URL, the request will bypass all caching layers (CDN, Dispatcher) and will hit Publisher.
  2. Publisher will use standard error handler and return 404 response to apache.
  3. Apache will use ErrorDocument configuration and PassThrough configured error page path to Dispatcher
    /content/path/to/your/site/home/errors/404.html 
  4. The dispatcher will process the error page path (either from cache or from the publisher)
  5. The dispatcher will return the Formatted brand/site-specific error page to end-user

 

How this approach will help?

  1. Publisher will just do sling resolution of the requested page, and return a very lightweight response. This will reduce the processing load on the publisher.
  2. The dispatcher will cache the formatted error page, which will further reduce the load on the publisher.
  3. You can configure multiple error pages, one for each virtual host, or path based for same virtual host.

3 replies

Jagadeesh_Prakash
Community Advisor
Community Advisor
July 11, 2022

@yusheng you can refer to below URL for Customizing pages show by Error handler. Hope this is useful

 

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/customizing-errorhandler-pages.html?lang=en

 

Adobe Employee
July 11, 2022

AEM comes with a standard error handler for handling HTTP errors.

You can develop your own scripts to customize the pages shown by the error handler when an error is encountered. Your customized pages will be created under /apps and overlay the default pages (that are under /libs).

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/customizing-errorhandler-pages.html?lang=en 

http://www.aemcq5tutorials.com/tutorials/adobe-aem-cq5-tutorials/custom-error-pages-acs-commons-errorhandler/ 

 

Also, you should look for ACS 

https://adobe-consulting-services.github.io/acs-aem-commons/features/error-handler/index.html

Provide an author-able means for defining, creating and managing custom Error pages per content tree/site.

 

Mohit_KBansal
Adobe Employee
Mohit_KBansalAdobe EmployeeAccepted solution
Adobe Employee
July 11, 2022

Considering your use case, you should handle error processing at the apache level. 

 

What does it mean?

AEM returns standard error page (consider it as a very lightweight error page response). Idea is to keep error processing very light weight on AEM.

 

How should error handle work?

Create an error page in AEM like other pages of your site.

/content/path/to/your/site/home/errors/404.html
/content/path/to/your/site/home/errors/500.html

Error response should be handed at the apache level. In your virtual host configuration, add a Document with the path of AEM page. 

ErrorDocument 404 /content/path/to/your/site/home/errors/404.html 
ErrorDocument 401 /content/path/to/your/site/home/errors/500.html

 

How error processing will work?

  1. When a user hit a random URL, the request will bypass all caching layers (CDN, Dispatcher) and will hit Publisher.
  2. Publisher will use standard error handler and return 404 response to apache.
  3. Apache will use ErrorDocument configuration and PassThrough configured error page path to Dispatcher
    /content/path/to/your/site/home/errors/404.html 
  4. The dispatcher will process the error page path (either from cache or from the publisher)
  5. The dispatcher will return the Formatted brand/site-specific error page to end-user

 

How this approach will help?

  1. Publisher will just do sling resolution of the requested page, and return a very lightweight response. This will reduce the processing load on the publisher.
  2. The dispatcher will cache the formatted error page, which will further reduce the load on the publisher.
  3. You can configure multiple error pages, one for each virtual host, or path based for same virtual host.
YuShengAuthor
Level 3
July 12, 2022

Thank you for the reply, the information helps a lot!