Search code examples
phpapachecachinginternal-server-errorlast-modified

500 Internal Server Error (invalid characters) on LastModified http header


I have a php download script that sends a Last-Modified http header like this:

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

that worked fine for a very long time. But now I tried to use that script in another project and this header line causes an Error 500 in xampp.

The logfile shows the message:

AH02429: Response header name 'Last Modified' contains invalid characters, aborting request

All examples that I can find in google (e.g. http-response-header-last-modified) and even documentations like Mozilla-Last-Modified or rfc7232#2.2 suggest the same format. So I am realy wondering why apache/xampp have a problem with that header.


Solution

  • Like noticed by cbroe there was an typo in my header-name. The point is, that maybe old servers did not complain about missspelled headers, and newer servers trigger an internal server error.

    The Correct line should be

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

    Last-Modified instead of Last Modified.