嗨,请帮我解决codeigniter中的URL问题。
我想要网址:www.mysite.com/category/pageurl
example1 : www.mysite.com/blog/pageurl
example2 : www.mysite.com/services/pageurl
example2 : www.mysite.com/about/pageurl
mycontroller文件
function postdata()
{
$post['url']= array
(
$category = $this->uri->segment(3),
$posturl = $this->uri->segment(4),
);
$this->Post_model->get_slug($category,$posturl);
$this->load->view('postdata',$post);
}
我的模型文件
function get_slug($category,$posturl)
{
return $this
->db
->get_where(
'post',
array(
'post_type'=>$category,
'post_url' => $posturl
)
)->result();
}
我的路线文件代码
$route['(:any)/(:any)'] = 'Post/postdata/$1/$2';
和我的观点
<?php
foreach($url as $post):
?>
<h1><?php echo $post->post_title;?> </h1>
<hr>
<p>
<?php echo $post->post_content;?>
</p>
<?php
endforeach;
?>