Thursday, March 10, 2022

[FIXED] Routing in Kohana in development

Issue

I am setting up my new web application using the Kohana framework.

I am using MAMP so the app is located in the htdocs folder, with this structure:

---htdocs
 --foo
  -application

I am getting this error when viewing http://localhost:8888/foo/

Kohana_HTTP_Exception[ 404 ]: The requested URL foo was not found on this server.

In the bootstrap.php the route is the default Kohana one

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

Solution

Check your application/bootstrap.php file for:

Kohana::init(array(
    'base_url'   => '/foo/',
));

This is required for Kohana to understand it's in /foo/ folder.

UPD The requested URL foo was not found on this server exception message is generated if no action_<action> method was found in Controller.

If no Route was found Unable to find a route to match the URI: exception message is genereted.

Not shure Routing works as expected, but it works ;).

So check your Controller file for apropriate action method.



Answered By - s.webbandit

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.