Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

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

Avatar

Level 2

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

 

3 Replies

Avatar

Community Advisor

@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-errordocume...

 

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

Avatar

Level 2

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 

Avatar

Community Advisor

HI @chandanaa9 
You can check the following vhosts file

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

 

<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