RFE: Directory- or page-specific 404 pages | Community
Skip to main content
March 12, 2026
New

RFE: Directory- or page-specific 404 pages

  • March 12, 2026
  • 1 reply
  • 24 views
Field Content
Request for Feature Enhancement (RFE) Summary: Allow defining custom 404 pages per specific page or directory (path) so that only the designated scopes show a tailored 404, different from the site-wide default.
Use-case: When users access 404s under landing pages (LPs) or other special sections, the site owner needs to show a section-specific 404 that provides targeted guidance (e.g., relevant links, promotions, or contact paths) appropriate to that section.
Current/Experienced Behavior: It is not possible to create a dedicated 404 page for a specific page or directory. All 404 responses fall back to the global default, which cannot convey section-appropriate guidance.
Improved/Expected Behavior: Enable configuration to display a unique 404 page only for the specified page/directory scope, while keeping the default 404 for other areas of the site.
Environment Details (AEM version/service pack, any other specifics if applicable): Experience Manager as a Cloud Service
Customer-name/Organization name: asahi kasei
Screenshot (if applicable):  
Code package (if applicable):  

    1 reply

    giuseppebaglio
    Level 10
    March 12, 2026

    hi ​@yoshida.mhx

    To serve dedicated 404 pages for a very specific pages without affecting the rest of the website you can use either granular Apache Dispatcher routing or the ACS AEM Commons Error Page Handler.

    Approach 1: Apache Dispatcher Location Directives

    The most performant approach is to configure Apache to intercept errors and serve specific pages based on the exact requested URL path. This is done using <Location> or <LocationMatch> blocks within your Virtual Host configuration.​

    To implement this, modify your site's .vhost file within the Dispatcher configuration:

    1. Enable the Dispatcher to pass errors to Apache by setting DispatcherPassError 1.​

    2. Define your global ErrorDocument fallback for the rest of the website.​

    3. Add specific <Location> (for exact page paths) or <LocationMatch> (for regex-matched sets of pages) blocks below the global declaration to override the 404 behavior for your specific pages.

    <VirtualHost *:80>
    # 1. Let Apache handle the errors instead of passing them directly
    <IfModule disp_apache2.c>
    DispatcherPassError 1
    </IfModule>

    # 2. General fallback for the whole website
    ErrorDocument 404 /content/mysite/us/en/errors/404.html

    # 3a. Override for a specific directory and its sub-pages
    <LocationMatch "^/content/mysite/us/en/special-campaign/.*">
    ErrorDocument 404 /content/mysite/us/en/special-campaign/404.html
    </LocationMatch>

    # 3b. Override for one exact specific page
    <Location "/content/mysite/us/en/highly-specific-page.html">
    ErrorDocument 404 /content/mysite/us/en/custom-isolated-404.html
    </Location>
    </VirtualHost>

    This approach requires a Cloud Manager deployment to update the paths, so it is best for paths that do not change frequently.

     

    Approach 2: ACS AEM Commons Error Page Handler

    If content authors need the flexibility to define specific 404 pages dynamically without developer intervention, the ACS AEM Commons package provides an authorable solution.​ While I haven’t personally tested it, it should function effectively.

    Instead of hardcoding paths in Apache, this tool allows authors to set error pages directly via Page Properties.​

    1. Install and enable the ACS AEM Commons Error Page Handler in your AEM environment.​

    2. Navigate to the Page Properties of the specific page (or the parent page of the specific set).

    3. Under the Advanced tab, locate the Error Pages field (which you have to add btw)

    4. Browse and select the dedicated 404 page for that specific section.

    When a 404 occurs, the script will traverse upward from the missing page's requested path. It will find the custom error page defined on that specific parent page and display it, while the rest of the site will naturally fall back to the site-wide configuration.