简体   繁体   中英

Error page not found manipulation URL with slug in CodeIgniter

I am getting error page not found when I implementation URL using slug.

This is code in controller

function view($slug)
{
    $this->data['halaman_item'] = $this->mhalaman->get_profil($slug);

    if (empty($this->data['halaman_item'])) {
        show_404();
    }

    $this->data['title'] = $this->data['halaman_item']['judul'];            $this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
    $this->data['contents'] = $this->load->view('mahasiswa/profil/sejarah', $this->data, true);
    $this->load->view('template/wrapper/mahasiswa/wrapper_content',$this->data);
}

Model

function get_profil($slug = FALSE)
{
    if ($slug === FALSE)
    {
        $query = $this->db->get($this->tbl_halaman);
        return $query->result_array();
    }

    $query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
    return $query->row_array();
}

Route

$route['profil/view'] = "profil/view";
$route['profil/(:any)'] = "profil/view/$1";
$route['profil'] = "profil";

When I run this link tkd/index.php/mahasiswa/profil/sejarah is 404 page is not found. may be you know where is the probelm.

Help me what to do. Thank you.

好吧,不知道您应用程序其余部分的$this->data['halaman_item'] ...第一件事就是确保$this->data['halaman_item']确实有数据...因为如果没有,它会先调用show_404发生。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM