CodeIgniter Forums
306 route error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: 306 route error (/showthread.php?tid=64822)



306 route error - munhzol - 03-29-2016

CI 3.0.6

in config/route.php
$route['(:any)'] = "site/$1";

in application/site/Someclass.php
and declared index(), somefunction()

when I loading host/someclass it's load index function ok. but host/someclass/somefunction not works. it's shows 404.

is there any error or something? or ?


RE: 306 route error - munhzol - 03-29-2016

It was worked fine in 2x


RE: 306 route error - kilishan - 03-29-2016

I believe :any has changed to not support multiple segments in CI3. So, that route is only getting the first segment, I believe. You can use a regular expression to capture absolutely everything. Something like:

Code:
$route['(.+)'] = "site/$1";



RE: 306 route error - munhzol - 03-29-2016

(03-29-2016, 10:34 PM)kilishan Wrote: I believe :any has changed to not support multiple segments in CI3. So, that route is only getting the first segment, I believe. You can use a regular expression to capture absolutely everything. Something like:

Code:
$route['(.+)'] = "site/$1";

thank you. but when in config $route['api/(:any)'] = "api/$1"; then host/api/someclass/somfunction/var1/var2.... its working.


RE: 306 route error - arma7x - 03-29-2016

$route['(:any)/(:any)'] = "site/$1/$2";
$route['(:any)'] = "site/$1";
Have you try this? I'm not sure it's working.


RE: 306 route error - munhzol - 03-30-2016

(03-29-2016, 11:49 PM)arma7x Wrote: $route['(:any)/(:any)'] = "site/$1/$2";
$route['(:any)'] = "site/$1";
Have you try this? I'm not sure it's working.

$route['admin/(.+)'] = 'admin/$1';

$route['(.+)'] = "site/$1";

it's working.