Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 找不到CodeIgniter默认控制器_Php_Codeigniter - Fatal编程技术网

Php 找不到CodeIgniter默认控制器

Php 找不到CodeIgniter默认控制器,php,codeigniter,Php,Codeigniter,在routes.php中,我将默认控制器设置为: $route['default_controller'] = 'index_controller'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; index\u controller位于标题为:index\u controller.php 索引控制器的内容是: <?php if ( ! defined('BASEPATH')) exit('No

在routes.php中,我将默认控制器设置为:

$route['default_controller'] = 'index_controller';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
index\u controller位于标题为:
index\u controller.php
索引控制器的内容是:

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

class Index_controller extends CI_Controller {

 function __construct()
 {
   parent::__construct();
 }

 function index()
 {
   $this->load->helper('url');
   $this->load->view('login_view'); 
 }

}
?>

我得到的错误是:

404找不到页面
找不到您请求的页面。

如果codeigniter的版本为3,则文件名应以大写字母开头

接下来,您是否添加了
.htaccess
文件??如果没有,请使用index.php访问url。 或者使用以下代码从url中删除index.php

RewriteEngine On
RewriteBase /CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

将此文件添加到根目录中,名称为
.htaccess
看起来
index\u controller
是一个控制器名称,而不是URL。你应该写一个URL

比如,

$route['default_controller'] =  'home';
$route['home']               =  'back/homeController';

您正在使用哪个版本的codeigniter???@user3574766重命名
$route['default_controller']='index_controller'
只需
$route['default\u controller']='Index'
(注意大写的
I
)路由可以指向小写名称,但如果是CI v3+则控制器文件必须是ucfirst(即
Index\u controller.php
),答案对您有帮助吗??请在这里添加您在代码中遗漏的注释。它将帮助其他人。