用户
 找回密码
 入住 CI 中国社区
搜索
查看: 6105|回复: 10
收起左侧

[HELP] 设置了url_suffix后分页问题

[复制链接]
发表于 2009-9-20 16:28:19 | 显示全部楼层 |阅读模式
本帖最后由 chenhan 于 2009-9-20 22:50 编辑

1、出于SEO考虑,想把有些页面可以用HTML后缀访问,看了手册发现设置了$config['url_suffix'] = ".html"就能实现以HTML后缀访问;可是问题来了,在分页地址也自动加了html,变成了/zufang/index.html/1,这个好像不大好吧,请问有什么解决的办法可以变成:/zufang/index/1
2、另外请问大家做站有设置这个成为HTML吗?还是通过REWRITE来实现伪静态的呢

代码贴出来大家看看:

$this->load->library('pagination');//分页类
  $config['base_url'] = site_url('/qiuzhu/index'); //注意"index"必须要.
  $config['total_rows'] = $this->qiuzhum->get_qzcount('61');//数据总行数   
        $config['per_page'] = 15; //每页显示数
        $config['uri_segment'] =3;
  $config['num_links'] = 6;
  $config['full_tag_open'] = '<p>';
  $config['full_tag_close'] = '</p>';
  $config['first_link'] = '首页';
  $config['last_link'] = '尾页';
  $config['next_link'] = '下一页';
  $config['prev_link'] = '前一页';
  $this->pagination->initialize($config); //初始化分页
  $data['pagelink'] =$this->pagination->create_links();
  $StartRow = 0;  //开始显示记录的编号
  if($this->uri->segment(3)){  //如果为空,则表示第1页
   $StartRow = $this->uri->segment(3);  //获得开始显示的记录编号
  }
  $data['qzdata']=$this->qiuzhum->get_qzlist('61',$StartRow,$config['per_page']);
  $this->load->view('qiuzhu',$data);
发表于 2009-9-20 16:47:08 | 显示全部楼层
分页代码写的不对
 楼主| 发表于 2009-9-20 22:48:30 | 显示全部楼层
楼上是说是我的代码写得不对,如果对的话就不会/zufang/index.html/1是吗?
发表于 2009-9-20 23:51:05 | 显示全部楼层
我记得的是分页类不支持 URL 后缀,不知道新版修正没修正?
 楼主| 发表于 2009-9-21 09:43:26 | 显示全部楼层
我就是不要后缀的,可是设置后他自己加上去的,我希望地址是:/zufang/index/1

怎么样才能不要加上后缀呢
发表于 2009-9-21 11:26:19 | 显示全部楼层
$config['base_url'] = site_url('/qiuzhu/index'); //注意"index"必须要.

这句写的不对,site_url()会自动追加后缀

要改成 = site_url().'/qiuzhu/index';

然后扩展分页类追加后缀
 楼主| 发表于 2009-9-21 14:38:49 | 显示全部楼层
请问哪里有例子吗?
发表于 2009-9-21 14:45:01 | 显示全部楼层
这个就要自己扩展咯,分页类的源码不难
 楼主| 发表于 2009-9-22 10:04:17 | 显示全部楼层
哈哈,没注意看手册,用base_url就正常了,谢谢二位了
发表于 2013-8-6 11:53:06 | 显示全部楼层
chenhan 发表于 2009-9-22 10:04
哈哈,没注意看手册,用base_url就正常了,谢谢二位了

{:soso_e179:}学习了,我也是刚碰到这个问题!!!

本版积分规则