• The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Automatic redirecting to custom errorpages in PHP

GuiltySpark

New Pleskian
Server operating system version
Ubuntu 24.04.01 LTS
Plesk version and microupdate number
18.0.66 #2
Hi, I am setting up a new server, its similar to my old server, except the OS (CentOS7 v Ubuntu24.04), they are both running Apache 2.4.58 and PHP 8.27.
I'm using nginx on both servers and I have custom error pages.

This works as expected on the new server in displaying my errorpage for a 404 for example.

To use this errorpages in code (PHP), I simply used:

PHP:
header('HTTP/1.0 404 Not Found');
exit();

And Apache would redirect to the custom error page, this is not working on the new server, and I don't know why, instead I just get a standard (Chrome I think) 404 error.

I know I can use the header + include to force it, but it was a little more elegant with the old server, any ideas?

Thanks

Mac
 
Hi, I am setting up a new server, its similar to my old server, except the OS (CentOS7 v Ubuntu24.04), they are both running Apache 2.4.58 and PHP 8.27.
I'm using nginx on both servers and I have custom error pages.

This works as expected on the new server in displaying my errorpage for a 404 for example.

To use this errorpages in code (PHP), I simply used:

PHP:
header('HTTP/1.0 404 Not Found');
exit();

And Apache would redirect to the custom error page, this is not working on the new server, and I don't know why, instead I just get a standard (Chrome I think) 404 error.

I know I can use the header + include to force it, but it was a little more elegant with the old server, any ideas?

Thanks

Mac

For more: ConcretesrichmondVa.Com

Check your Apache configuration to ensure the ErrorDocument directive is set properly. For example:
Code:
ErrorDocument 404 /path-to-your-custom-error-page.html

Make sure this directive is in the right VirtualHost block and that the file path is accessible. also verify that your .htaccess file, if used, has the same settings as the old server. Finally, ensure that PHP's display_errors is turned off in php.ini, as it might override custom error handling. This should help get your custom error pages working again!
 
Thanks Tim,

The custom error pages do work, if I go to an invalid url, I get my custom error pages. The issue is with redirecting from PHP. On the old server I only had to call "header('HTTP/1.0 404 Not Found');" and Apache would redirect to the custom error page, but on the new server, it appears to do nothing.

I have double checked all the Additional directives for Apache in Plesk and they are identical across both servers.
 
Back
Top