您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

WordPress博客首页如何静态

2025/11/18 19:18:18发布31次查看
wordpress博客首页静态的方法如下:
首先新建一个php文件,文字可以自取,自己要记住,比如index-html.php,然后复制以下代码:
<?php$basecmsurl = "https://www.ziyouwu.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 = "https://www.ziyouwu.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");?>
将文件上传到网站根目录后直接打开浏览器访问该文件即可为wordpress首页生成html。
生成index.html文件后,我们要注意的是我们直接访问自己的域名和访问域名+index.html都会显示首页这样的会搜索引擎会认为你在制造重复页面,会给网站带来一定的负面影响,下面给出解决此问题的方法(访问index.html301转跳到/,即去除掉首页url中的index.html)
apache下301跳转代码
rewriteengine on rewritebase / rewritecond %{the_request} ^[a-z]{3,9}\ /index\.(php|html|htm)\ http/ rewriterule ^index\.(php|html|htm)$ http://www.ziyouwu.com/ [r=301,l]
nginx下的解决方法
location / { if (!-e $request_filename){ rewrite ^/(.*)$ /index.html/$1 last; }}
这样首页静态就可以完全使用了!
更多wordpress相关技术文章,请访问wordpress教程栏目进行学习!
以上就是wordpress博客首页如何静态的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product