查看文章
 
WordPress中文tag出现错误(出现404页面或无法访问)的解决方法
2011/06/28 10:35

昨天安装好的WordPress出现了错误,相信这个错误应该是很多同学都出现过的,那就是首页、页面、分类和固定链接都正常(godaddy免费windows主机,iis7,并在web.config文件中写好了伪静态规则,后台开启固定链接),但是当我点击中文的tag的时候,出现了“该页无法访问”或404错误,开始百思不得其解,一位是伪静态出问题了,但是所有的固定连接都是正常的,于是想到是不是中文tag编码问题,就开始到网上找答案,但是网上有不同的解决方法,我都试过,不过可惜只有一种方法有效,下面为大家一一介绍。
方法一:在文件中找到如下代码,首先备份你的WordPress/wp-includes/rewrite.php文件,以防修改出错。然后打开rewrite.php寻找如下代码:
function get_tag_permastruct() {

if (isset($this->tag_structure)) {

return $this->tag_structure;

}

if (empty($this->permalink_structure)) {

$this->tag_structure = ”;

return false;

}

if (empty($this->tag_base))

$this->tag_structure = $this->front . ‘tag/’;

else

$this->tag_structure = $this->tag_base . ‘/’;

$this->tag_structure .= ‘%tag%’;

return $this->tag_structure;

并将其中的if (!empty($this->permalink_structure)) {
修改为if (! empty($this->permalink_structure)) {
注意只加了一个英文!号,经测试,本人使用了这种方法产生了效果。

方法二:(本方法本人尝试无效)
打开wp-includes/classes.php文件,

if ( isset($_SERVER['PATH_INFO']) )

$pathinfo = $_SERVER['PATH_INFO'];

else

$pathinfo = ”;

$pathinfo_array = explode(‘?’, $pathinfo);

$pathinfo = str_replace(“%”, “%25″, $pathinfo_array[0]);

$req_uri = $_SERVER['REQUEST_URI'];

修改为:

if ( isset($_SERVER['PATH_INFO']) )

$pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], “UTF-8″, “GBK”);

else

$pathinfo = ”;

$pathinfo_array = explode(‘?’, $pathinfo);

$pathinfo = str_replace(“%”, “%25″, $pathinfo_array[0]);

$req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], “UTF-8″, “GBK”);

据说此法只在windows主机有效,但虽然我的也是windows主机,但是不知道为什么没有效果,不过幸好问题已经解决,我也是不求甚解的人,就得过且过了,欢迎大家还有什么好的方法和我一起分享!

 

 

来源 周志军


类别:工作记||添加到搜藏 |分享到i贴吧|浏览(417)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu