【发布时间】:2015-03-01 12:04:36
【问题描述】:
刚刚下载了CI 2.2,将文件夹重命名为Test1,复制到xampp的htdocs文件夹中。
通过访问http://localhost/Test1 测试该站点,它启动了欢迎消息。现在向控制器(“admin”)和其中的控制器(home.php)添加了一个文件夹。所以结构是:
controllers
--> admin
--> home.php
--> index.php
--> welcome.php
而home.php中的代码是
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
public function index()
{
echo 'Hello';
}
}
当我尝试访问 http://localhost/Test1/admin/home 或 http://localhost/Test1/admin/home/index 时,它说找不到对象(404 错误)。
我还尝试将$route['admin'] = "admin/home"; 添加到application\config\routes.php,以便我可以以http://localhost/Test1/admin 的身份访问,但没有用。我错过了一个设置吗?
【问题讨论】:
-
你在配置文件中设置了base_url吗?
-
使用这个 $config['base_url']= 'localhost/Test1';没有改变任何东西:(
标签: php codeigniter controller routes