我在header.php中锚定如下:
<a href="<?php base_url();>backend">Backend</a>
在Controllers文件夹中也有名为backend.php的控制器。
我还在routes.php文件中路由了这段代码,如
$route('default_controller')='frontend';
$route('backend')='backend';
后端控制器页面是:
<?php
class Backend extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index(){
$data['title'] = 'Backend Page';
$this->load->view('templates/header', $data);
$this->load->view('backend/reg', $data);
$this->load->view('templates/footer');
}
}
虽然找不到错误404页面。
答案 0 :(得分:0)
试试这个:
<a href = "<?php echo base_url();?>/pathforyourbackend">Backend </a> // include also the folder where your backend file is stored
我希望这会有所帮助。
答案 1 :(得分:0)
确保所有控制器和模型等 Ucfirst 示例Frontend.php而不是frontend.php
Codeigniter文档http://www.codeigniter.com/docs
在application.config / autoload.php中自动加载 url帮助
从
更改路线 $route('default_controller') ='frontend';
到
$route['default_controller'] = "frontend";
$route['backend'] = "backend";
我没有设置你的配置,用htaccess删除index.php,然后在链接中使用index.php。
<a href="<?php echo base_url('index.php/backend');">Backend</a>
示例控制器/ Backend.php
<?php
class Backend extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index(){
$data['title'] = 'Backend Page';
$this->load->view('templates/header', $data);
$this->load->view('backend/reg', $data);
$this->load->view('templates/footer');
}
}
示例控制器/ Frontend.php
<?php
class Frontend extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index(){
$data['title'] = 'Frontend Page';
$this->load->view('templates/header', $data);
$this->load->view('frontend/reg', $data);
$this->load->view('templates/footer');
}
}
此处链接htaccess示例,用于删除Windows os https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter
上的index.php