如何访问controllers下的文件夹的控制器。
本帖最后由 ghost2006n 于 2013-4-22 11:12 编辑我之前设置了一些设置,去掉了index.php在地址栏的显示,设置了URI路由。在地址栏输入localhost就可以显示网站主页。现在在controllers下建立了一个admin文件夹,里面写了个控制器,现在在地址栏输入http://localhost/admin/index/view却显示404错误页。请教达人到底该如何修改和访问。以下是我的文件的代码:
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1
config.php
$config['base_url'] = 'http://localhost/';
$config['index_page'] = 'index.php';
routes.php
$route['default_controller'] = 'index';
$route['(:any)'] = 'index/$1';
$route['404_override'] = '';
admin文件夹下的index.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语句,且无错误。
求各位大大指教! default controller 不能叫index dickfu 发表于 2013-4-22 13:32 static/image/common/back.gif
default controller 不能叫index
那该怎么改呢 http://codeigniter.org.cn/user_guide/general/reserved_names.html ghost2006n 发表于 2013-4-22 14:31 static/image/common/back.gif
那该怎么改呢
用 home 做默认控制器吧,我就是用的这个,总之别用 index
页:
[1]