如何创建codeigniter url到人类友好的url


how to create codeigniter url to human friendly url?

我的项目差不多完成了。但我只需要一个Seo友好的url为我的项目我当前的url是

http://localhost/example/product/category/1

我想把这个url转换成这个

http://localhost/example/product/category/name-of-category

请帮帮我

您需要使用类似slug的东西

public function category($slug)
{
    $query = $this->db->get_where('posts', array('slug' => $slug), 1);
    // Fetch the post row, display the post view, etc...
}


用破折号分隔单词

 $slug = url_title($title, 'dash', true);

你需要注意这个段符是唯一的:)