【发布时间】:2018-05-09 13:12:02
【问题描述】:
我想在输入错误的url时显示404页面
真实网址
https://localhost.com/posts/hello_world
错误网址
https://localhost.com/posts/dsadasd
404 的错误网址
控制器
public function read($slug_posts)
{
$options = $this->options_model->listing();
$posts = $this->posts_model->read($slug_posts);
#$listing = $this->posts_model->home();
$data = array( 'title' => $posts->post_title.' – '.$options->option_title,
'description' => $posts->post_description,
'posts' => $posts,
#'listing' => $listing,
'content' => 'posts/read'
);
$this->load->view('layout/wrapper', $data, FALSE);
}
【问题讨论】:
-
我们不能坐在这里为你写代码。如果您提供您当前的立场以及您所做的一切,这对您和我们都会有所帮助。
-
您目前如何解决这个问题?如果您相应地编辑您的问题,您可能会收到一些反馈,例如,您的控制器
posts的外观如何? -
if( $post == 'wrong' ) show_404(); -
@BrianGottier 不工作 :(
-
@Vickel 添加控制器
标签: codeigniter controller http-status-code-404