开发者

Kohana controller URI basics

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.


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜