我有以下SEO参数的功能,不知何故,当url包含字母以外的字符时,它将剥离并且页面将指向404,我的一些url将包含中文字符,如何才能接受中文字符?< / p>
public function seoUrl($string)
{
//Lower case everything
$string = strtolower($string);
//Make alphanumeric (removes all other characters)
$string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean up multiple dashes or whitespaces
$string = preg_replace("/[\s-]+/", " ", $string);
//Convert whitespaces and underscore to dash
$string = preg_replace("/[\s_]/", "-", $string);
return $string;
}