CodeIgniter Forums
Routes doesn't work - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: Routes doesn't work (/showthread.php?tid=1113)

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


I have problem with routes in CI 3.0 RC2. I want change url from:

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.

$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:[methods from Wolontariusze]
and controller Panel with url:
Code:[methods from Panel]

And I want to do url's:
Code:[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:

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

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

Thanks guys for help, I got it Smile