CI框架URL中传中文的解决
在application/libraries下建立自己的文件MY_URI.php,并继承自system/core下的原生URI类,
重写_filter_uri方法:
function _filter_uri($str) { if ($str != '' AND $this->config->item('permitted_uri_chars') != '') { $str = urlencode($str); if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str)) { exit('The URI you submitted has disallowed characters.'); } $str = urldecode($str); } return $str; }
按照CI操作手册中的说法,当在application/libraries存在自己的类时,CI将使用用户自定义的类,
PS:对于 2.0 以后的版本,要放到 application/core 目录下