WordPress博客首页如何静态(wordpress博客页面)
正文内容:
php零基础到就业直播视频课:进入学习
API 文档、设计、调试、自动化测试一体化协作工具:点击使用
WordPress博客首页静态的方法如下:
首先新建一个php文件,文字可以自取,自己要记住,比如index-html.php,然后复制以下代码:
<?php$baseCmsUrl = "http://ziyouwu";$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://ziyouwu";$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://ziyouwu/ [R=301,L]
nginx下的解决方法
location / { if (!-e $request_filename){ rewrite ^/(.*)$ /index.html/$1 last; }}
这样首页静态就可以完全使用了!
更多wordpress相关技术文章,请访问wordpress教程栏目进行学习!
本文从互联网转载,来源地址:inhv.cn/wordpress/207679.html,原作者保留一切权利,若侵权或引用不当,请联系测速网(inhv.cn)删除。【测速网,优质云服务器提供商】
《WordPress博客首页如何静态(wordpress博客页面)》来自互联网同行内容,若有侵权,请联系我们删除!
免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。