Last active
November 15, 2017 14:17
-
-
Save andandehei/8449152 to your computer and use it in GitHub Desktop.
wordpress加速:首页静态化超强提高wordpress速度
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//将以下代码复制到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