开发者

How do I get Kohana to call a specific controller?

My routing is set up like this:

Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
    'controller' => 'static',
    'action'     => 'index',
));

so that typing in:

http://localhost/et/testkohana4/

calls action_index on Controller_Static as it should.

However, when I type in:

http://localhost/et/testkohana4/test

I expect it to say "cannot find Cont开发者_Go百科roller_Test" but instead, Kohana misses it and I get a message from Apache that says "The requested URL /testkohana4/index.php/test was not found on this server."

Even when I put in a file under the controller directory called test.php with the class Controller_Test in it, I still get the page-not-found error.

How can I get Kohana to call a specific controller when I type its name in the URL?


Edit: The correct solution as provided in this answers comments was to change the .htaccess RewriteBase value to

RewriteBase /et/testkohana4/

(<controller>(<action>(/<id>)))

There's a mistake in your route. There is no forward slash at the beginning of (<action> ... That should be (/<action> ...

Those <blocks> are dynamic segments in the URL. So in this example:

http://localhost/et/testkohana4/test

Would result in this being called:

  • Controller: et
  • Action: testkohana4
  • ID: test

That should work for you. Hope that helped.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜