[英]CodeIgniter Default Controller not found
In routes.php i've set the default controller as so: 在routes.php中,我将默认控制器设置为:
$route['default_controller'] = 'index_controller';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
index_controller is in the controllers folder titled: index_controller.php
The content of index_controller
is: index_controller是在标题为控制器文件夹:
index_controller.php
的含量index_controller
是:
<?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');
}
}
?>
The error I get is: 我得到的错误是:
404 Page Not Found The page you requested was not found. 404找不到页面未找到您请求的页面。
If the version of your codeigniter is 3, then file name should start with capital letter. 如果您的codeigniter版本是3,则文件名应以大写字母开头。
Next, have you added .htaccess
file ?? 接下来,您是否添加了
.htaccess
文件? if not access the url with index.php. 如果不使用index.php访问URL。 or use following code to remove the index.php from url.
或使用以下代码从网址中删除index.php。
RewriteEngine On
RewriteBase /CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
add this file in root with name .htaccess
将此文件添加到名为
.htaccess
根目录中
It looks like index_controller
is a Controller name, not URL. 看起来
index_controller
是控制器名称,而不是URL。 You should write URL. 您应该写URL。
For example; 例如;
$route['default_controller'] = 'home';
$route['home'] = 'back/homeController';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.