您现在的位置是:首页 > 教程 > WordPress教程WordPress教程
WordPress博客首页怎么实现静态
代真2023-06-19 00:11:41WordPress教程已有人查阅
导读WordPress博客首页静态的方法如下:首先新建一个php文件,文字可以自取,自己要记住,比如index-html.php,
WordPress博客首页静态的方法如下:首先新建一个php文件,文字可以自取,自己要记住,比如index-html.php,然后复制以下代码:
<?php
$baseCmsUrl = "https:// .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:// .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:// .ziyouwu.com/ [R=301,L]
nginx下的解决方法
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.html/$1 last;
}
}
这样首页静态就可以 基本使用了!
本文标签:
很赞哦! ()
相关文章
随机图文
-
wordpress发短信功能的使用方法介绍
支持手机号注册/登录,重要事件短信通知等。目前仅支持阿里云短信服务手机注册/登录/绑定只需要开启功能,在服务商申请短信模版即可使用。 -
wordpress建站和安装方法
准备环境首先用wordpress需要系统支持,相应的php mysql和apache等环境。这里我们以win系统为例,下载安装一个wmap环境。比如appserv服务,这里直接安装好了。 -
wordpress主题本地安装的方法
wordpress主题怎么本地安装?wordpress主题本地安装的方法:首先登陆wordpress站点,点击外观-主题 -
wordpress使用主题的方法
WordPress闻名于世之一就是拥有众多的主题模板,包含有博客主题、CMS主题、淘宝客主题、网店主题、企业主题、图片主题等等
留言与评论 (共有 条评论) |