Php CodeIgniter-使用slug从url隐藏函数名

Php CodeIgniter-使用slug从url隐藏函数名,php,codeigniter,routes,Php,Codeigniter,Routes,我有一个控制器引线&有两个功能 索引 潜在客户详细信息 这是我的密码 class Leads extends CI_Controller { public function index(){} public function lead_details($slug){} 它的工作原理如下 www.mysite.com/leads/ This will access to index function www.mysite.com/leads/lead_details/nice-no

我有一个控制器引线&有两个功能

  • 索引
  • 潜在客户详细信息
  • 这是我的密码

    class Leads extends CI_Controller {
      public function index(){}
      public function lead_details($slug){}
    
    它的工作原理如下

    www.mysite.com/leads/    This will access to index function
    www.mysite.com/leads/lead_details/nice-not-to-have-2
    
    现在我想知道细节,比如

    www.mysite.com/leads/nice-not-to-have-2
    
    我试过了,但它和索引函数混淆了

    $route['leads/(:any)']  = 'leads/lead_details'
    
    注意:这不是重复的

    问题在于索引函数。如何使用application/config/routes.php实现这一点

    示例:lead/index显示错误,因为它指向lead_details功能,更正如下:

    $route['leads/index']  = 'leads';
    $route['leads(/:any)'] = 'leads/lead_details$1';
    
    带有
    leads
    作为第一段的URL,第二段中的任何内容都将重新映射到
    leads
    类/控制器和
    lead\u详细信息
    方法/函数

    如果键入:

    • 无论是
      yoursite.com/leads
      还是
      yoursite.com/leads/index
      ,它都将路由到
      leads
      类的
      index
      功能
    • yoursite.com/leads/nice-not-to-have-2
      to
      leads/lead\u详细信息

    CI_版本上测试:'3.0-dev'

    那么www.mysite.com/leads/nice-not-to-have-2和www.mysite.com/leads/index有什么区别呢?这里的index是函数名www.mysite.com/leads/index,当它指向lead_details函数时,请告诉我错误