Custom Error Pages Dispatcher AEM as Cloude Service PassThrough not working
Current Implementation:
We have previously implemented custom error page handling using ACS AEM Commons Error Page Handler in AMS. Now, we are migrating the code to AEM as a Cloud Service. We have implemented the same approach by adding a folder under ui.apps:
/apps/acs-commons/components/utilities/errorpagehandler/404.jsp
This folder contains all the custom error pages related to the project. Additionally, we created another folder at:
/apps/sling/servlet/errorhandler/default.jsp
This folder refers to the ACS Commons path. The configuration works, and we are getting custom 404 pages. However, when we deploy the code and try to access other ACS Commons lists through AEM sites, those pages are blocked because /apps/acs-commons is overriding the path. We tried a different approach using ErrorDocument directives through the dispatcher, which also works by redirecting to the custom 404 page mentioned in the ErrorDocument directive. The issue is that it should not show in the URL; it should redirect internally like a passthrough.
Example:
If we hit www.example.com/sites/page1.html and this page does not exist, it should maintain the same URL in the browser but internally redirect to the 404 page.
What We Have Tried:
We used the following header:
Header set x-aem-error-pass "true" "expr=%{REQUEST_STATUS} >= 400 && %{REQUEST_STATUS} < 600"However, this header is not getting set on the pages, and it still redirects to the 404 page.
Is there a better and optimal approach to achieve this?