在wordpress中,可以使用url伪静态来让地址看起来更好看,也更有利于SEO。但是中文的情况比较让人头疼,每次都会跳转到404页面。
经过一阵子的度娘和谷歌之后终于找到了完美解决URL中出现中文的办法:
打开wordpress\wp-includes目录下的class-wp.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'); 本文转自齐师傅博客园博客,原文链接http://www.cnblogs.com/youring2/archive/2013/03/20/2971008.html,如需转载请自行联系原作者