WordPress URL Rewrite静态组件导致中文标签无法访问的解决方法
IIS这样的错误导致在WordPress中,对$_SERVER['PATH_INFO']和$_SERVER['REQUEST_URI']取值时就会取到GBK编码的url,但是WordPresss是用UTF-8编码的,所以中文就转成了乱码,再转换成SQL去数据库查询的时候就怎么也找不到记录了。 打开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”); |