グーグルで調べているとすばらしいページにぶち当たった。
Movable Type を始める前に設定しておきたい 10 の項目
おお、俺、php化やってみたい!
てなわけで、一通り設定する。
ん!?
あ、あれ~~~
ルートにindex.htmlがあるとindex.phpより優先されて表示される。
必ずindex.htmlがないことを確認しましょう。
index.htmlも構築している場合は、FTPで削除しましょう。
こんなんでハマルの俺ぐらいだろうけど…orz
テンプレート(index.php,archives.php)の先頭に下記を追加した。
<?php
$ts = getlastmod();
doConditionalGet($ts);
function doConditionalGet($timestamp) {
// A PHP implementation of conditional get, see
// http://fishbowl.pastiche.org/archives/001132.html
$last_modified = gmdate('D, d M Y H:i:s T', $timestamp);
$etag = '"'.md5($last_modified).'"';
// Send the headers
header("Last-Modified: $last_modified");
header("ETag: $etag");
// See if the client has provided the required headers
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ?
stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) :
false;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ?
stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) :
false;
if (!$if_modified_since && !$if_none_match) {
return;
}
// At least one of the headers is there - check them
if ($if_none_match && $if_none_match != $etag) {
return; // etag is there but doesn't match
}
if ($if_modified_since && $if_modified_since != $last_modified) {
return; // if-modified-since is there but doesn't match
}
// Nothing has changed since their last request - serve a 304 and exit
header('HTTP/1.1 304 Not Modified');
exit;
}
?>