Skip to main content
Level 1
May 4, 2026
Question

AEMaaCS CDN – Custom 404 handling (EN + FR)

  • May 4, 2026
  • 3 replies
  • 108 views

Hi all,
We’re using AEM as a Cloud Service CDN configuration where requests are routed to Azure Blob Storage using a one-to-one mapping between CDN YAML path patterns and blob container folder structure.

kind: "CDN"
version: "1"
data:
originSelectors:
rules:
- name: "page-origin"
when:
reqProperty: "path"
matches: "^/(page)(/.*)?$"
action:
selectOrigin: "blob-storage-origin"

Problem: When a path maps to blob storage but the file does not exist (origin returns 404), we want to display a custom 404 experience and it must support both locales:
English 404 for non-/fr paths
French 404 for /fr/* paths
Question: Is there any supported way in AEMaaCS CDN YAML to:
map/override origin 404 to a custom page/route (rewrite or redirect), and
do this per locale (EN vs FR)?
We looked at errorPages but schema validation indicates only errorPages.spa is supported (no custom “rules” / mapping).
If CDN config cannot do this, what is the recommended approach in AEMaaCS for this use case (Dispatcher error document, AEM Sling error handler, app-level logic, etc.)?
Thanks!
 

    3 replies

    Adobe Employee
    May 5, 2026

    Hello ​@SiddhiDa2 

    At this time, AEM as a Cloud Service CDN configuration does not support mapping an origin-returned 404 to a custom localized page body. The CDN errorPages capability is intended for cases where the Adobe-managed CDN cannot reach the origin, and the supported schema today is the SPA-based configuration documented by Adobe rather than rule-based per-status/per-locale mappings.
    Sources:

    For your use case, the recommended pattern is to implement the custom 404 handling behind the CDN, using either:

    • an AEM Sling error handler for a true branded 404 response with locale-aware rendering, or
    • Dispatcher ErrorDocument handling if a simpler/static error page model is preferred.

    This approach allows you to preserve the correct HTTP 404 status while serving different experiences for:

    • French requests under /fr/*
    • English requests for non-/fr/* paths

    Adobe's AEMaaCS guidance for custom error pages points to customizing AEM-served or Dispatcher-served error responses rather than using CDN YAML for origin 404 remapping.

    chaudharynick
    Level 4
    May 5, 2026

    No. As you correctly identified, the AEMaaCS CDN YAML does not currently support error page handling for the website, but it does handle the global outage error page.

     

    You have to use the Dispatcher ErrorDocument configuration to handle it.

     

    example:

    # ---------------------------------------------------------
    # Default Fallback Error Page (English)
    # ---------------------------------------------------------
    ErrorDocument 404 /content/mysite/us/en/errors/404.html
    ErrorDocument 500 /content/mysite/us/en/errors/500.html

    # ---------------------------------------------------------
    # Localized Error Pages (French)
    # ---------------------------------------------------------
    <LocationMatch "^/fr/.*">
    ErrorDocument 404 /content/mysite/fr/errors/404.html
    ErrorDocument 500 /content/mysite/fr/errors/500.html
    </LocationMatch>

     

    Level 4
    May 11, 2026

    Hi ​@SiddhiDa2 ,

    Both answers above are correct on the CDN limitation. To add a bit more practical detail on the Sling error handler approach since that’s likely the cleanest path for your locale-aware requirement.
    The AEM Sling error handler gives you full control over the response body while preserving the correct 404 HTTP status, which is what you want for SEO. The locale detection happens naturally because the error handler runs within AEM’s request context, so you have access to the request path and can branch your rendering logic based on whether the path starts with /fr/ or not.
    The basic structure is a servlet registered to handle 404 responses, something like a 404.jsp or a Sling servlet mapped to the error handler path under /apps/your-project/errorhandler/. Inside that handler you resolve the appropriate error page from your content tree based on the locale detected from the request path /content/mysite/fr/errors/404 for French requests and /content/mysite/en/errors/404 for everything else and then include that page’s content in the response.
    The key advantage over the Dispatcher ErrorDocument approach for your use case is that the Sling handler runs before the Dispatcher caches anything, so you get dynamic locale detection without needing separate Dispatcher farm configurations per locale. The Dispatcher ErrorDocument approach works well for simple static error pages but gets complicated when you need locale branching across multiple vhosts or farms.
    One thing to watch out for make sure your error page content paths are excluded from Dispatcher caching or configured to cache separately per locale, otherwise your first cached error response will be served to all subsequent requests regardless of locale until the cache is invalidated.