A certain .php code does not work on a domain: 500 internal server error

Created:

2017-08-04 22:17:12 UTC

Modified:

2017-08-08 13:09:34 UTC

0

Was this article helpful?


Have more questions?

Submit a request

A certain .php code does not work on a domain: 500 internal server error

Symptoms

A certain .php page does not work on a domain (e.g: example.com/index.php):

500 internal server error

The rest of pages work correctly.

The following error is found in /var/www/vhosts/system/example.com/logs/error_log:

[Fri Aug 04 17:20:23.268449 2017] [http:error] [pid 14289] [client 203.0.113.2:53533] AH02429: Response header name 'Last Modified' contains invalid characters, aborting request

index.php file contains the following line:

header('Last Modified: '. gmdate('D, d M Y H:i:s') .' GMT');

Cause

Error in syntax: HTTP headers cannot have spaces, so Last-Modified should be used instead.

Resolution

Change the code in index.php file: replace "Last Modified" with "Last-Modified" so that it looks like:

header('Last-Modified: '. gmdate('D, d M Y H:i:s') .' GMT');
Have more questions? Submit a request
Please sign in to leave a comment.