wordpress链接Permalinks有indexphp用404页跳转
02月 19th, 2008 feilong wordpress, 飞龙原创 532因为去年dreamhost空间被停,飞龙.org(飞龙的官方博客http://feilong.org/)遭停一个多月。过年了,2008年了我该把它重新搭建起来。通过理想空间的帮助,换了一个cpanel空间,把wordpress安装好,通过phpmyadmin数据库管理后台把去年日志导入(import),把日志永久链接( Permalinks)也设为去年那种格式: /%postname% 。结果页面无法访问,只能改为默认主题才可以访问。这个cpanel空间莫非不支持网址重写啊?
尝试用这种格式:/index.php/%postname%,发现也可以访问,原来index.php有网址重写的功效。但是日志里很多链接就必须修改成新的网址格式,有点麻烦。
wordpress原来那些日志怎么才能转到新设置的有/index.php的网址呢?试了很多办法,包括使用Dean’s Permalinks Migration、Permalink Redirect、301定向等方法,都没有成功。
飞龙偶尔看到智能跳转404页面的功能的文章,说是用一个404错误页可以解决这个问题。飞龙突然想到我的php空间是有cpanel调板的,里面好像有一个404错误的高级功能,何不试用一下?下面是飞龙尝试的过长,记录下来(更新地址http://feilong.org/404-shtml-wordpress-permalinks-index-php )并修订以找到更好办法。 。
效果是这样的:点击去年旧链接网址 http://feilong.org/404-shtml-wordpress-Permalinks-index-php
通过此404错误页,系统提示浏览者点击阅读http://feilong.org/404-shtml-wordpress-permalinks-index-php 。
方法一 404错误页实现智能跳转代码。飞龙第一次采用此方法,发现此404错误页跳转方法不利于seo优化和GOOGLE pr的信任度。于是不再采用,仅作参考。
一,Shtml版代码:
<html>
<head>
<meta http-equiv=’refresh’ content=’5; url=http://www.mydot.org<!–#echo var=”REQUEST_URI” –>’>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<STYLE type=text/css>
BODY {
FONT-SIZE: 12px;
SCROLLBAR-ARROW-COLOR: #000000;
FONT-FAMILY: “Verdana”, “Arial”, “Helvetica”, “sans-serif”;
SCROLLBAR-BASE-COLOR: #828fa2;
}
TD {
FONT-SIZE: 12px;
FONT-FAMILY: “Verdana”, “Arial”, “Helvetica”, “sans-serif”;
}
A:active {
COLOR: #000000; TEXT-DECORATION: underline
}
A:visited {
COLOR: #455164; TEXT-DECORATION: underline
}
A:hover {
COLOR: #000000; TEXT-DECORATION: none
}
A:link {
COLOR: #455164; TEXT-DECORATION: underline
}
</STYLE>
<TITLE>本站已经启用新的国际域名feilong.ORG,系统为你定向到新网址</TITLE>
</head>
<body leftmargin=”10″ topmargin=”10″ marginwidth=”10″ marginheight=”10″ style=”table-layout:fixed; word-break:break-all”>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ height=”95%” align=”center”>
<tr align=”center” valign=”middle”>
<td>
<table border=”0″ cellspacing=”1″ cellpadding=”10″ bgcolor=”#555555″ width=”60%”>
<tr>
<td bgcolor=”#EEEEEE” align=”center”>
<p><b>本站启用新的国际域名<a href=http://feilong.org>feilong.ORG</a>,系统正在为你重新定向到新站中的相应网页….</b></p></td>
</tr>
<tr>
<td bgcolor=”#EEEEEE” align=”left”>
<p>目前你访问旧域名形式:http://feilong.org<!–#echo var=”REQUEST_URI” –><br><br>
系统在5秒后为你重定向到<b>feilong.ORG</b>相应新页面<br>
如果不想等待,请直接点击l链接:<a href=http://feilong.org<!–#echo var=”REQUEST_URI” –>>http://feilong.org<!–#echo var=”REQUEST_URI” –></a><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</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>
本站起用新域名访问,你目前访问的页面是 http://feilong.org<?=$_SERVER[’REQUEST_URI’]?>
系统为你重新定向到新站相应的页面 http://feilong.org<?=$_SERVER[’REQUEST_URI’]?>或等5秒后,系统自动跳转到新站相应的页面
</body>
</html>
使用方法:与xrea404一样用,
三,飞龙(http://feilong.org )提示:
如果是cpanel空间,将第一个按你实际网址情况修改后保存为404.shtml,然后放到网站的根目录下就可以了。或者用cpanel的高级404错误功能,把代码粘贴到里面,结果是一样的。其实有更好的办法处理:看我的飞龙wordpress主题中加404错误页方法:链接:http://feilong.org/wordpress-404
作者:周志恒
链接:http://www.hengss.com
整理:飞龙.org
更新:http://feilong.org/404-shtml-wordpress-Permalinks-index-php

to “wordpress链接Permalinks有indexphp用404页跳转”
By yeye on Jun 5, 2008
学习了。支持飞龙!