CodeIgniter Forums
Routes doesn't work - 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: Routes doesn't work (/showthread.php?tid=1113)



Routes doesn't work - vertisan - 02-12-2015

Hi!

I have problem with routes in CI 3.0 RC2. I want change url from:
Code:
http://example.com/main/logowanie
to
Code:
http://example.com/logowanie

I have code:
PHP Code:
$route['main/logowanie'] = 'logowanie'
but I have error 404 on both url's.

Where is the problem?


RE: Routes doesn't work - Rufnex - 02-12-2015

What is your controller .. main oder logowanie ? If it is main, an your method is logowanie you have to route like that:

PHP Code:
$route['logowanie'] = 'main/logowanie'



RE: Routes doesn't work - CroNiX - 02-12-2015

Your order is reversed for your route.

Code:
$route[the url to respond to] = the controller/method to execute

$route['logowanie'] = 'main/logowanie';



RE: Routes doesn't work - vertisan - 02-12-2015

Thanks guys, my bad Tongue

I have one more question, how to route all methods from first controller to second?
Ex. I have controller Wolontariusze with url's:
Code:
http://example.com/wolontariusze/[methods from Wolontariusze]
and controller Panel with url:
Code:
http://example.com/panel/[methods from Panel]

And I want to do url's:
Code:
http://example.com/panel/wolontariusze/[methods from Wolontariusze]

I create this route:
PHP Code:
$route['panel/wolontariusze/(:any)'] = 'wolontariusze/$1'
but doesn't like me and i got error 404


RE: Routes doesn't work - ivantcholakov - 02-12-2015

In CodeIgniter 3 the scope of (:any) is one segment only. Try this:

Code:
$route['panel/wolontariusze/(.+)'] = 'wolontariusze/$1';



RE: Routes doesn't work - vertisan - 02-12-2015

Thanks guys for help, I got it Smile