Apache is not showing 404 at missing page URL instead redirecting to error page URL | Community
Skip to main content
New Participant
February 20, 2024
Question

Apache is not showing 404 at missing page URL instead redirecting to error page URL

  • February 20, 2024
  • 2 replies
  • 911 views

I want to handle the error scenarios from WebServer(Apache) instead of AEM sling error handler as I wanted error pages to get cached in the dispatcher

when I let apache handle the errors i followed 2 steps

step1:

added the below code to a .conf file and added that to the individual vhost

<LocationMatch \.html$>
   ErrorDocument 404 /content/examplesite/en/errors/404.html
 #ErrorDocument <ANY OTHER ERROR CODE> <PATH IN YOUR DOCROOT>
</LocationMatch>
step2 : changed the dispatcherPassError to 1 
now I'm getting redirected to http://www.example.com/errors/404.html instead of keeping the requested URL which should be something like http://www.example.com/non-existent-page.html

how can I achieve the below:

 non-existent-page.html does not exist, and the user is trying to access that page and triggered a 404 error.

Can I show the requested page URL: http://www.example.com/non-existent-page.html

instead it is redirecting to the error page URL:http://www.example.com/errors/404.html

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

arunpatidar
New Participant
February 21, 2024

HI @chandanaa9 
You can check the following vhosts file

https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/dispatcher.cloud/src/conf.d/available_vhosts/aemlab.vhost 

 

<LocationMatch /> ErrorDocument 404 /content/aemlab/oneweb/errorpages/404.html ErrorDocument 403 /content/aemlab/oneweb/errorpages/403.html ErrorDocument 500 /content/aemlab/oneweb/errorpages/500.html </LocationMatch> <IfModule disp_apache2.c> # Enabled to allow rewrites to take affect and not be ignored by the dispatcher module DispatcherUseProcessedURL On # Default setting to allow all errors to come from the aem instance DispatcherPassError 1 </IfModule>
Arun Patidar
Imran__Khan
New Participant
February 21, 2024

@chandanaa9 I was also having this issue last week and got resolved after setting below configurations

 

DispatcherUseProcessedURL On

DispatcherPassError 1

 

Follow below link for more details

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-dispatcher-errordocument-url-not-showing-up/td-p/539501

 

For showing same url instead for redirection you can also use ACS Commons 404 error page handling

https://adobe-consulting-services.github.io/acs-aem-commons/features/error-handler/index.html

New Participant
March 7, 2024

i have already did all this , the problem i trying tio solve is that it is getting redirected to error page instead of staying on the existing URL