Score:0

Apache ErrorDocument subject to Rewrite Rules?

sa flag
mdb

We are working on an AEM dispatcher configuration, and are trying to correctly configure our ErrorDocument settings in conjunction with rewrite rules. In short - it's unclear whether ErrorDocument will run through rewrite rules or be processed instead of them.

We have a multi-tenant configuration on the dispatcher, with each vhost normalizing inbound requests to the correct path on the publisher. We are seeing our 404 errors redirected (301'ed) to the 404 page rather than it displaying it with a 404 response. (We don't see a 404 at the browser at all).

Side note: this is a recent issue because of changes we made to the dispatcher rewrite rules, so we believe the ErrorDocument is being rewritten, but are looking for confirmation as our SDLC is kind of slow.

<IfModule disp_apache2.c>
    DispatcherUseProcessedURL   1
    DispatcherPassError     1
</IfModule>

Define CONTENT_ROOT /content/tenant
ErrorDocument 404 /content/tenant/404.html

RewriteMap  lc int:tolower

# 301 requests coming to the document root or with .html
RewriteCond %{REQUEST_URI} ^/content/tenant/(.+)\.html$ [NC,OR]
RewriteCond %{REQUEST_URI} ^/content/tenant/(.+) [NC,OR]
RewriteCond %{REQUEST_URI} ^/(.+)\.html$ [NC]
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/${lc:%1} [R=301,QSA,L]

# Now we have a clean URL, we need to map it to the document root
RewriteRule   ^/(.+)$   ${CONTENT_ROOT}/${lc:$1}.html  [L,PT,QSD]  

The issue we're seeing is that the 404 document is already written to the correct path. Should we be using ErrorDocument 404 /404instead to prevent rewrite rules from 301'ing it (as it would above) -- or does ErrorDocument happen instead of other rules?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.