Typecho生成静态首页index.html文件
教程
在网站根目录新建文件f5.php然后里面写入下面的代码。<?php
$nowtime=time();
$pastsec = $nowtime - $_GET["t"];
if($pastsec<600)
{
exit; //10分钟更新一次,时间可以自己调整
}
ob_start(); //打开缓冲区
include("index.php");
$content = ob_get_contents(); //得到缓冲区的内容
$content .= "\n"; //加上调用更新程序的代码
file_put_contents("index.html",$content);
if (!function_exists("file_put_contents"))
{
function file_put_contents($fn,$fs)
{
$fp=fopen($fn,"w+");
fputs($fp,$fs);
fclose($fp);
}
}
?>
然后浏览器打开你的域名/f5.php,打开后你将看到的还是你的首页,刷新你的网站根目录,看到一个index.html就说明生成成功了,然后查看首页代码,末尾出现“
补充
我的index.html生成成功了,但是每次访问末尾都没有出现“
如果你用的是宝塔按照下图,将index.html调整到index.php上边保存即可。
如果你用的是cPanel在.htaccess中添加DirectoryIndex index.html index.php index.htm保存即可