飞龙博客

飞龙博客 飞龙在天

wordpress Permalinks有index.php用404页跳转

feilong.org 修订于2008-02-19 01:28:07 300 次浏览

去年dreamhost空间被停,飞龙博客也因此遭停一个多月。通过理想空间的帮助,飞龙换了一个虚拟主机,重新安装好wordpress,然后通过phpmyadmin把日志导入(import),再把日志永久链接(Permalinks)设为去年那种格式: /%postname% ,结果所有网页无法访问!莫非新的虚拟主机不支持url重写?

飞龙发现index.php有网址重写的功效,于是用这种格式:/index.php/%postname%,发现日志又可以访问了。但是日志里很多链接必须修改成新网址格式,太麻烦了。

旧日志链接如何批量修订,使它们带有/index.php?飞龙试了Dean's Permalinks Migration、Permalink Redirect、301定向等方法,没有成功。

偶尔看到404页面智能跳转的文章,说用404错误页可解决此问题。飞龙突然想到虚拟主机的cpanel里面有404错误的高级功能,何不试用一下?飞龙想要实现这样的效果:

用户打开旧网址:feilong.org/404-shtml-wordpress-Permalinks-index-php
404错误页提示用户阅读新网址:feilong.org/index.php/404-shtml-wordpress-permalinks-index-php

方法一、shtml格式的404错误页,飞龙第一次采用此方法,但发现它不利seo优化和GOOGLE pr的信任度,于是不再采用。代码如下,仅作参考。

<html>
<head>
<meta http-equiv='refresh' content='5; url=http://feilong.org<!--#echo var="REQUEST_URI" -->'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>本站启用新域名feilong.ORG!</TITLE>
</head>

<body>
<p>你访问的旧域名:http://feilong.org<!--#echo var="REQUEST_URI" --></p>
<p>5秒后为你重定向到:<a href=http://feilong.org/index.php/<!--#echo var="REQUEST_URI" -->>http://feilong.org<!--#echo var="REQUEST_URI" --></a></p>
</body>
</html>

方法二,404错误页,PHP代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>404</title>
<meta http-equiv='refresh' content='5; url=http://feilong.org<?=$_SERVER[REQUEST_URI]?>'>
</head>
<body>
<p>
目前访问网址:http://feilong.org<?=$_SERVER['REQUEST_URI']?>,5秒后为你重定向到:http://feilong.org/index.php/<?=$_SERVER['REQUEST_URI']?>
</p>
</body>
</html>

三,飞龙提示以上404错误页的使用方法。
按你实际网址情况修改后保存为404.shtml,然后放到网站的根目录下。或到cpanel的高级404错误功能,把以上代码粘贴到里面。

四、更好的404解决办法:http://feilong.org/wordpress-404

更新网址:https://feilong.org/404-shtml-wordpress-permalinks-index-php
最初发布:20080219 01:28:07 feilong.org 于广州

加入收藏夹,查看更方便。

所在分类: wordpress

新作:

旧文:

blog money bui 教程 echarts 教程 eclipse 教程 html css 教程 IT趋势 js 教程 json 教程 mysql 教程 nodejs npm 教程 onblog SQLite 教程 tutorials vscode 教程 wap网站 winpe启动盘 wordpress 主机推荐 书法 前端开发 博客 名企名网 国学 域名注册 常用软件 建站程序 操作系统 教程 数码 无线上网 日记 电子商务 电脑笔记本 网站 网站优化 网站开发 网站推广 网站策划 网络 虚拟现实 默认