CodeIgniter Forums
Auto set routes in codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Auto set routes in codeigniter (/showthread.php?tid=62301)



Auto set routes in codeigniter - wolfgang1983 - 06-30-2015

I would like to know if it is possible to get codeigniter routes.php to auto detect routes.

Because each time I have to create a route like below

PHP Code:
$route['route=common/dashboard'] = 'common/dashboard/index';
$route['route=user/user'] = 'user/user/index';
$route['route=user/user/edit(:any)'] = 'user/user/edit$1'

I can get route by just doing this echo $this->input->get('route');

I also have enabled $config['uri_protocol'] = 'QUERY_STRING'; to make it work with my htaccess

Example Link http://localhost/project-dashboard/index.php/?route=common/dashboard working perfect

I will save a lot of time. Any suggestions.


RE: Auto set routes in codeigniter - colonelclick - 07-03-2015

Based on your description, everything should work fine if you simply delete your custom routes. As long as your routes match the format controller/method/parameters and your paths are set correctly, you do not need to manually define routes.


RE: Auto set routes in codeigniter - skunkbad - 07-03-2015

If all you want to do is be able to see your route, you don't need to have a query string. Just use the URI class:


PHP Code:
$this->uri->uri_string();