Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

Avatar

Level 3

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!

1 Accepted Solution

Avatar

Correct answer by
Employee

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.

View solution in original post

4 Replies

Avatar

Level 6

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-errorh... 

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

 

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.

 

Avatar

Correct answer by
Employee

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.