Entry
Lost Last-Modified when set apache to use PHP4 module for all .htm/.html files. Can one have PHP4 parse .htm/.html and keep the Last-Modified header?
Mar 15th, 2008 21:21
dman, ha mo, Cinley Rodick, Martin Kenny, Jun Liang Chiu, Matt Gregory, Tomaz Borstnar, http://www.ttnr.org
No. The server actually inserts the last-modified information when you
use a header. If you are running the .htm/.html pages through PHP then
you will not get this information since the server is not reading the
files, it is getting the results of a script (stdout).
I would not recommend this setup at any rate. Instead, you should
use .phtml or .php extensions on your script files and allow
normal .html files to be handled by the server. I would put last-
modified into a database and update it when the site is updated.
To include the last-modified information in your PHP scripts,
you can use the header() function:
<?
header("Last-Modified: " . gmdate("D, d M Y H:i:s",
filemtime($SCRIPT_FILENAME)) . " GMT");
?>
To make this happen for all your PHP scripts, you can add this to your
auto_prepend_file as specified in the php.ini configuration file.