Welcome Guest, Not a member yet? Register   Sign In
Routes doesn't work
#1

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?
Reply
#2

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'

Reply
#3

(This post was last modified: 02-12-2015, 03:45 PM by CroNiX.)

Your order is reversed for your route.

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

$route['logowanie'] = 'main/logowanie';
Reply
#4

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
Reply
#5

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

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

Thanks guys for help, I got it Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB