Skip to content

Instantly share code, notes, and snippets.

@andandehei
Last active November 15, 2017 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andandehei/8449152 to your computer and use it in GitHub Desktop.
Save andandehei/8449152 to your computer and use it in GitHub Desktop.
wordpress加速:首页静态化超强提高wordpress速度
//将以下代码复制到index_html.php文件中,然后上传到网站根目录下
<?php
$baseCmsUrl = "http://www.wenchenhk.com";
$dmPageName = "index.php";
$stPageName = "index.html";
$tureStFile = dirname(__FILE__).'/'.$stPageName;
{
$body = file_get_contents($baseCmsUrl.'/'.$dmPageName);
$fp = fopen($tureStFile, 'w');
fwrite($fp, $body);
fclose($fp);
}
if(file_exists("index.html"))
{
unlink("index.html");
}
$baseCmsUrl = "http://www.wenchenhk.com";
$dmPageName = "index.php";
$stPageName = "index.html";
$tureStFile = dirname(__FILE__).'/'.$stPageName;
{
$body = file_get_contents($baseCmsUrl.'/'.$dmPageName);
$fp = fopen($tureStFile, 'w');
fwrite($fp, $body);
fclose($fp);
}
header("Location:$baseCmsUrl/index.html");
?>
//将以下代码粘贴到.htaccess文件中
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTP/
RewriteRule ^index\.(php|html|htm)$ http://wenchenhk.com/ [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment