Php CodeIgniter控制器始终调用索引函数

Php CodeIgniter控制器始终调用索引函数,php,html,codeigniter,php-5.5,Php,Html,Codeigniter,Php 5.5,每当我尝试添加一个新的控制器并通过URL访问各种公共函数时,我都不会根据URL请求只重定向到index()函数而不访问函数 示例代码是 <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class courses extends CI_Controller { public function __construct() { parent:

每当我尝试添加一个新的控制器并通过URL访问各种公共函数时,我都不会根据URL请求只重定向到index()函数而不访问函数

示例代码是

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class courses extends CI_Controller
{    
    public function __construct()    
    {    
        parent::__construct();
        $this->load->model('user_model');
        define('CurrPage', 'Courses');
    }    
    public function index()
    {
        echo "is in Index";    
    }    
    public function categoryInfo()
    {
        echo "is in cat";    
    }

    public function c()
    {
        echo "is in c";    
    }  
}

尝试将其添加到config/routes.php

  $route['default_controller'] = "home";
  $route['404_override'] = 'courses';  
  $route['v/(:any)']= "video_single/index"; 
  $route['userInfo/(:any)']= "userInfo/index";
$controllers = array('test' );
foreach($controllers as $controller) {
    $route[$controller] = $controller."/index";
    $route[$controller."/(:any)"] = $controller."/$1";
}

config/routes.php
$route['default\u controller']=“home”中写入的内容$路线['404_覆盖']='courses'$路由['v/(:any)]=“视频/单个/索引”$路由['userInfo/(:any)]=“userInfo/索引”;删除所有并使用此
$route['default\u controller']=“home”$路由['404_覆盖']=''并重试。显示应用程序代码/config/routes.pho添加的路由代码请检查