用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2343|回复: 4
收起左侧

如何访问controllers下的文件夹的控制器。

[复制链接]
发表于 2013-4-22 11:10:18 | 显示全部楼层 |阅读模式
本帖最后由 ghost2006n 于 2013-4-22 11:12 编辑

我之前设置了一些设置,去掉了index.php在地址栏的显示,设置了URI路由。在地址栏输入localhost就可以显示网站主页。现在在controllers下建立了一个admin文件夹,里面写了个控制器,现在在地址栏输入http://localhost/admin/index/view却显示404错误页。请教达人到底该如何修改和访问。以下是我的文件的代码:
.htaccess
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-f
  3. RewriteCond $1 !^(index\.php|images|robots\.txt)
  4. RewriteRule ^(.*)$ index.php/$1 [L]
复制代码


config.php
PHP复制代码
$config['base_url'] = 'http://localhost/';
$config['index_page'] = 'index.php';
复制代码


routes.php
PHP复制代码
$route['default_controller'] = 'index';
$route['(:any)'] = 'index/$1';
$route['404_override'] = '';
复制代码


admin文件夹下的index.php
PHP复制代码
<?php
class Index extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }
    public function view()
    {
        $this->load->view('admin/index_v');
    }
}
复制代码


index_v.php只是一些简单的HTML语句,且无错误。

求各位大大指教!
发表于 2013-4-22 13:32:25 | 显示全部楼层
default controller 不能叫index
 楼主| 发表于 2013-4-22 14:31:44 | 显示全部楼层
dickfu 发表于 2013-4-22 13:32
default controller 不能叫index

那该怎么改呢
发表于 2013-4-22 16:16:37 | 显示全部楼层
发表于 2013-4-22 19:12:06 | 显示全部楼层
ghost2006n 发表于 2013-4-22 14:31
那该怎么改呢

用 home 做默认控制器吧,我就是用的这个,总之别用 index

本版积分规则