如何从codeigniter中的url中删除控制器名称?

时间:2017-09-13 05:43:32

标签: php codeigniter

url:example

controller_name/method_name/parameter

Colleges/index/autonomus-institute

控制器:

public function index($university_type)
{
    $data['uni'] = $this->dependent->type($university_type);
    $data['student_id'] = $this->session->userdata('student_id');
    $this->load->view('header',$data);
    $this->load->view('university',$data);
}

视图:

<script>
    $(document).ready(function(){
        $(".university").click(function(){
            university = this.id;
            window.location.href = "<?php echo base_url(); ?>colleges/index/"+university;
        });
    });
</script>

route.php

$route['default_controller'] = 'test';
$route['404_override'] = '';
$route['translate_uri_dashes'] = TRUE;

$route['index'] = "colleges/index/";

在这段代码中我有控制器的名称索引,我加载了一个名为university的视图文件。现在,我想从url中删除控制器名称,因为我在我的route.php文件中定义但它不起作用。那么,如何从网址中删除控制器名称?请帮帮我。

谢谢

0 个答案:

没有答案