Dispatcher Redirection and Error Handling
Hi Team,
I have the below scenario -
In my rewrite rules I have written the below sequence -
1.
RewriteRule ^/$ /content/xyz/us/en/home-page.html [R=301,L]
As seen the above redirect points the root request to home-page.html
2.
RewriteRule ^/content/xyz/us/en/(.*)$ /$1 [NE,L,R=301]
As seen here we are shortening the URL to eliminate /content/xyz/us/en from the request URL
3.
RewriteRule ^/(.*)$ /content/xyz/us/en/$1 [NC,PT,L]
This rewrite is being written to append the URL back again and forward to publish
The above redirects are working fine for URL shortening on browser and then forwarding the complete path to publish.
4. The Vhost file contains the following -
<IfModule disp_apache2.c>
# Enabled to allow rewrites to take affect and not be ignored by the dispatcher module
DispatcherUseProcessedURL On
# Default setting (0) to allow all errors to come from the aem instance
DispatcherPassError 1
</IfModule>
ErrorDocument 404 /content/xyz/us/en/errors/404.html
ErrorDocument 500 /content/xyz/us/en/errors/500.html
ErrorDocument 502 /content/xyz/us/en/errors/500.html
The problem is that for incorrect URLs the ErrorDocument is not being picked up - We are directly spooling the publish's error page on dispatcher.
Please find the logs for the same -
172.17.0.1 "localhost" - [05/Aug/2022:15:12:21 +0000] "GET /content/xyz/us/en/abc.html HTTP/1.1" 301 233 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0"
172.17.0.1 "localhost" - [05/Aug/2022:15:12:21 +0000] "GET /abc.html HTTP/1.1" 404 2400 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0"
[05/Aug/2022:15:12:21 +0000] "GET /content/xyz/us/en/abc.html HTTP/1.1" 404 none [publishfarm/0] 9ms "localhost"
As seen the Dispatcher is not showing the 404 page from ErrorDocument.

Can you please let me know where the issue is ?
@arunpatidar , @kautuk_sahni - Any quick help on this ?
