我被要求研究CodeIgniter 3项目中的default_controller似乎没有被调用的问题。相反,我们看到一个404错误。CodeIgniter 3不调用默认控制器?
在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'.Any错误? –