【发布时间】:2017-02-19 03:10:32
【问题描述】:
我被要求调查 CodeIgniter 3 项目中的 default_controller 似乎没有被调用的问题。相反,我们看到的是 404 错误。
在application/controllers文件夹中有一个Welcome.php文件,内容如下:
class Welcome extends CI_Controller {
public function __construct()
{
parent::__construct();
// Your own constructor code
}
public function index()
{
print('hello');
$this->load->view('welcome_message');
}
}
application/config/routes.php 文件有:
$route['default_controller'] = "welcome";
我只看到 404,没有看到预期的文本。
将print 语句添加到routes.php 表明它正在被加载。此外,将其显式绑定到路由会调用它,但不会在将其设置为默认控制器时调用。
$route['blah'] = "welcome"
谁能建议可能发生的事情?
顺便说一句,我们在 Ubuntu 16.04 机器上使用 PHP7。
【问题讨论】:
-
你的
.htaccess文件呢? -
怎么样?我应该检查什么?
-
使用
localhost/project_name/welcome。有什么错误吗? -
@AndreM 有什么更新吗?解决了吗?
-
@AndreM 如果它没有 CI 所期望的标准规则,即重写为 index.php,那么这将失败。
标签: php codeigniter codeigniter-3