mod_autoindex accessibility: extend built-in module or replace with scripted generator?
0 reputation · 27 Feb 2021, 20:29 UTC
0 reputation · 27 Feb 2021, 20:29 UTC
Directory listings served by mod_autoindex in Apache httpd 2.4.x emit HTML 4.01 Transitional markup with a <table> structure, deprecated attributes, and no ARIA roles. Screen readers announce the output as an unlabeled table without file-type or size context, failing WCAG 2.1 AA.
IndexOptions +FancyIndexing +HTMLTable and inject accessible markup via HeaderName and ReadmeName. Preserves native sorting (?C=N;O=D), icon mapping, and byte-range caching, but cannot add role or aria-label to generated <th>/<td> elements without modifying C source.mod_autoindex and serve a scripted index that emits semantic HTML5 (<nav>, <ol>, <li>) with live regions for sort state. Achieves full WCAG 2.1 AA compliance but loses built-in performance, caching, and requires replicating query-string sorting and icon logic.Upstream has not added an IndexOptions Accessible flag because changing the default DOCTYPE and table structure would break existing HeaderName/ReadmeName templates that embed raw <tr><td> fragments. Third-party patches (e.g., Debian's autoindex-accessible) remain unmerged due to the major-version bump policy.
Which approach should a site adopt when the constraint is zero-downtime deployment across multiple virtual hosts with existing custom headers?
HeaderName injection reliably add role="region" aria-label="Directory listing" around the generated table without source changes?IndexOptions Accessible flag that would make approach 1 viable long-term?35775 reputation · 28 Feb 2021, 04:08 UTC
For a zero-downtime deployment across existing virtual hosts with custom headers, the initial step must be to extend the built-in module using HeaderName and ReadmeName wrappers, not immediate replacement.
The wrapper approach preserves critical native functionality (sorting, caching, icon mapping) required for zero-downtime transition. However, it is confirmed that this method does not achieve full WCAG 2.1 AA compliance because it cannot modify the internal <table> structure or add ARIA roles to table cells.
HeaderName and ReadmeName content to ensure they do not create invalid HTML nesting when wrapped by an outer <div role="region" aria-label="Directory listing">.?C=N;O=D), icon rendering, and IndexIgnore behavior against the native mod_autoindex output using curl.apachectl configtest followed by a graceful reload across all affected hosts.To refine the recommendation, confirm if the existing custom headers contain raw <tr> or <td> fragments that would conflict with an outer <div> wrapper.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 28 Feb 2021, 05:51 UTC
The HeaderName approach cannot reliably add role=\"region\" or aria-label to the generated <table> because Apache's directive only prepends/appends content—it doesn't wrap existing output. The generated table has no container element to target with attributes.
If your custom headers don't embed raw <tr><td> fragments, you could prepend <div role=\"region\" aria-label=\"Directory listing\"> and append </div>, but this creates invalid HTML nesting since the table structure isn't actually wrapped. Screen readers would still encounter an unlabeled table.
Test this by creating a header file with <div role=\"region\" aria-label=\"Directory listing\"> and using curl -s to inspect the raw HTML structure. You'll see the div appears before the table, not around it.
For true WCAG 2.1 AA compliance, a replacement script is necessary—either full CGI/WSGI or a hybrid using mod_rewrite to intercept requests and serve semantic HTML5 while preserving filesystem access patterns.