今天,没事,在按照,codeigniter中文官方网站上写一个博客
在config.php中配置$config['url_suffix'] = ".html";
控制器代码如下:
<?php
class Blog extends Controller{
function Blog(){
parent::Controller();
// $this->load->scaffolding('blog');
$this->load->helper('url');
$this->load->helper('form');
// $this->output->enable_profiler(TRUE);
}
function index(){
$data['title']='Hello Codeignier blog';
$data['content']='hello blog';
$data['query'] = $this->db->get('blog');
$this->load->view('blog_view',$data);
}
//评论
function comment(){
$data['title'] = 'comment page';
$data['content'] = 'welcome to comment this message!';
$this->db->where('blog_id',$this->uri->segment(3));
$data['query'] = $this->db->get('comment');
$this->load->view('comment_view',$data);
}
function insert(){
$this->db->insert('comment',$_POST);
redirect('blog/comment/'.$_POST['blog_id']);
// echo 'sdfsdfsdf';
}
function comment_insert(){
echo 'sdfsdfsdf';
}
}
然后,在浏览器输入:http://localhost/index.php/blog/comment_insert.html
居然报404错误,后来,得到Hex指点,原来是服务器问题,
后来,经过检查,本地apache.配置url重写规则,去掉了规则,正常!特此记录一下