我在应用程序/控制器中有2个控制器
我通过此网址访问welcome.php
http://opunletter.com/index.php/welcome/
但访问http://opunletter.com/index.php/pages/
时我收到以下错误
未找到404页面
找不到您请求的页面。
我无法找出错误。 Plz帮忙!
class Pages extends Controller {
function search($search_terms = '')
{
// If the form has been submitted, rewrite the URL so that the search
// terms can be passed as a parameter to the action. Note that there
// are some issues with certain characters here.
if ($this->input->post('q'))
{
redirect('/pages/search/' . $this->input->post('q'));
}
if ($search_terms)
{
// Load the model and perform the search
$this->load->model('page_model');
$results = $this->page_model->search($search_terms);
}
// Render the view, passing it the necessary data
$this->load->view('search_results', array(
'search_terms' => $search_terms,
'results' => @$results
));
}
}
答案 0 :(得分:1)
尝试使用extends CI_Controller
和construct()
,如下所示:
class Pages extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function search($search_terms = '')
{
...
}
}
您应该在CI3中使用控制器名称Pages.php
(大写第一个字母)而不是pages.php
。