views:

109

answers:

3

Re: Kohana v2.3.4.

Do I have to create a new controller for every URL which uses segment 2? In other words, if I want my URLs to be:

  • www.example.com/foo
  • www.example.com/bar

... do I need to create a unique controller for foo and a unique controller for bar? I'd like to create just one controller, if possible.

EDIT:

I'd like to avoid redirection at all costs, if possible.

+2  A: 

From here: http://docs.kohanaphp.com/general/routing

It looks like you can do:

$config['foo'] = 'controller/action'; // access at /foo
$config['bar'] = 'controller/action'; // access at /bar
Garrett
+1 for solving the problem.
Jeff
If I "solved" the problem, it should be the checked answer, no?
Garrett
@Garret.. hehe +1 :p
Thorpe Obazee
A: 

You can set up your router to redirect bar to foo. Don't forget to send http/302, in order to not confusing crawlers. Google doesn't like if more url's point to the same resource.

erenon
So, without redirection, you're saying "Yes, you do have to create multiple controllers?" Bummer.
Jeff
A: 

You do need to have a controller for every segment 2 , but if you only want a "foo" controller than you should use routing.

MarcoBarbosa