Custom 404 shows File not found for php files instead of redirecting
I am running PHP-FPM on WHM v72.05 with up to date software. I have a custom error page and I am having issues with the Apache ErrorDocument directive. I have the following in my .htaccess file
I am expecting the user to be directed to my error.php whenever the web page can't be found. If I access the following pages (which do not exist), Apache correctly redirects the user to the error.php page /a_page_which_does_not_exist /a_page_which_does_not_exist.html /a_page_which_does_not_exist.abc However, when I try to access a file with a .php extension that does not exist I get a blank page with the text "File not found. " I am expecting the user to be directed to error.php. I have tried the following:
and
but I still get the File not found text. My error page has to be a php file raher than a shtml file because it has specific server-side functionality. This used to work perfectly and I can only think that the change to PHP-FPM somehow changed this behaviour. Can anyone help?
RewriteEngine On
ErrorDocument 404 /error.php
I am expecting the user to be directed to my error.php whenever the web page can't be found. If I access the following pages (which do not exist), Apache correctly redirects the user to the error.php page /a_page_which_does_not_exist /a_page_which_does_not_exist.html /a_page_which_does_not_exist.abc However, when I try to access a file with a .php extension that does not exist I get a blank page with the text "File not found. " I am expecting the user to be directed to error.php. I have tried the following:
RewriteEngine On
ErrorDocument 404 /[Full Path To User]/error.php
and
RewriteEngine On
ErrorDocument 404 "some text"
but I still get the File not found text. My error page has to be a php file raher than a shtml file because it has specific server-side functionality. This used to work perfectly and I can only think that the change to PHP-FPM somehow changed this behaviour. Can anyone help?
-
Fixed it in the end by adding the following to the Post VirtualHost Include of the Apache Configuration Include Editor: Post VirtualHost Include0 -
Hello @monkey64, I'm glad to see you were able to solve the issue. It looks like the entry in your code is missing. Can you confirm the code you used for the Post VirtualHost Include field? Thank you. 0 -
Please ignore my previous post because I did not enter the correct code. Fixed it in the end by adding the following to the Post VirtualHost Include of the Apache Configuration Include Editor: ProxyErrorOverride On0 -
Hi @monkey64 Thanks for updating the thread with the solution that worked for you! I'll go ahead and mark this as resolved. Thanks! 0 -
Please ignore my previous post because I did not enter the correct code. Fixed it in the end by adding the following to the Post VirtualHost Include of the Apache Configuration Include Editor:
ProxyErrorOverride On
FWIW I have been dealing with this in another thread and you might be interested in this post by cPREX: The method you and I used breaks Webmail, and is not recommended (for other non-descript reasons). There is an include for the individual vhost file but cPREX reports is it currently broken, and he opened a case for it.0
Please sign in to leave a comment.
Comments
5 comments