【问题标题】:How to fix URL if deleted in codeigniter?如果在codeigniter中删除,如何修复URL?
【发布时间】:2017-11-22 08:08:42
【问题描述】:

这是我的网址http://localhost/ci_sai/home/detail/berhalusinasi-adik-bunuh-kakak-sepupu

如果此链接删除到http://localhost/ci_sai/home/detail/berhalusinasi-adik-bunuh,如何重定向到 ERROR 404

我正在使用 codeigniter

【问题讨论】:

    标签: php html codeigniter


    【解决方案1】:

    试试这个(示例):

    public function detail($slug='')
    {
        $page = $this->db->get_where('pages',['slug'=>$slug])->row();
        if(!$page) {
            show_404();
            return;
        }       
        [...]
    }
    

    public function detail($slug='')
    {
        $page = $this->db->get_where('pages',['slug'=>$slug])->row();
        if(!$page) redirect('home/detail/berhalusinasi-adik-bunuh');    
        [...]
    }
    

    【讨论】:

      猜你喜欢
      • 2012-08-10
      • 2015-10-24
      • 1970-01-01
      • 2022-06-21
      • 2018-03-18
      • 2014-09-08
      • 2012-12-19
      • 1970-01-01
      • 2017-12-12
      相关资源
      最近更新 更多