
在WordPress中中文Tag被定义为ASCII码,所以当搜索或者是通过Tag访问文章时会出现ASCII乱码路径的现象,在此给大家分享一下:
1.首先找到/wp-includes/rewrite.php 文件(在操作前请将其备份,以免修改出错。);
2.打开 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;
3.注意那行蓝色的代码,将其修改为:
if (! empty($this->permalink_structure)) {
就是在empty…前添加上一个英文的叹号”!”就是了。
4.保存!
还有种方法,我使用后整个提示错误,应该是空间不支持某个函数:
如何让WordPress的tag支持中文
今天,研究了一下午,终于找到WordPress自带的tag在IIS上不能支持中文的原因了,是因为IIS对中文url解析的问题,修改的方法很简单:
打开wp-includes\classes.php文件,找到第44行:
| 44 45 46 47 48 49 50 |
if ( isset($_SERVER[‘PATH_INFO’]) ) $pathinfo = $_SERVER[‘PATH_INFO’]; else $pathinfo = ”; $pathinfo_array = explode(‘?’, $pathinfo); |
把它改成这样:
| 44 45 46 47 48 49 50 |
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”); |
来源网站:黑色的午夜–徐继’S BLOG http://www.lhxuji.com
(C)版权所有,转载请注明【来源:午夜WuYeah.com » 解决wordpress的中文标签无法链接问题】

当前位置:
按你的方法,弄得我的博客都没办法访问了啊!
655555555555555