PHP SEO URL接受中文单词

时间:2016-04-28 02:41:08

标签: php seo

我有以下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;
} 

0 个答案:

没有答案