CodeIgniter - When using $route['(:any)'] = 'pages/view/$1' how to use other controllers?

后端 未结 3 682
死守一世寂寞
死守一世寂寞 2020-12-12 02:30

When using

$route[\'(:any)\'] = \'pages/view/$1\';

and I want to use other controllers in my routing for example:

$route[\'del         


        
3条回答
  •  孤城傲影
    2020-12-12 03:15

    I know that it's an old question, but I have found myself a nice solution.

    By default, CodeIgniter gives priority to URL's from routes config (even if straight controller, method etc. specified), so I have reversed this priority this way:

    In system/core/Router.php find _parse_routes method.

    Add this code under literal route match:

    $cont_segments = $this->_validate_request($this->uri->segments);
    if ($cont_segments == $this->uri->segments) {
      return $this->_set_request($cont_segments);
    }
    

    I agree, that this approach is kinda wrong, because we edit file from system/core, but I needed a fast soluttion to work with a lot of URL's.

提交回复
热议问题