遇到几个问题kohana框架:在ubuntu 12.04上路由和运行

I've started to learn kohana fews days ago and with my Zend Framework my learning experience seems to be fast until i run into couple of issues.

First of all i started the project in windows 7(dual booting with linux ubuntu 12.04). i know every link was fine before i started adding more pages to an admin app with kendo ui. i've added couple of routes to handle controllers in subfolders and to handle url with query string of the form ?bla=dkll&second=lkdjf (used by kendo grid to send unknown number of params based on users interaction with the grid).

First problem : under windows i would access any url except the root / eg localhost/admin/ (admin being my folder in htdocs) it gives me

ERROR: HTTP_Exception_404 [ 404 ]: The requested URL / was not found on this server :

83 try
84 {
85     if ( ! class_exists($prefix.$controller))
86     {
87         throw new HTTP_Exception_404('The requested URL :uri was not found on this server.',
88             array(':uri' => $request->uri()));
89     }
90
91     // Load the controller using reflection
92     $class = new ReflectionClass($prefix.$controller);

Second problem : Under ubuntu not only i have the same first problem but then i can't even hit other urls like localhost/admin/useraccess/login

Questions:

is the second problem related to the first one (obviously aside the '/' not found one) i have enabled on ubuntu mod_rewrite and the kohana install page is all green.

is there any other settings i forgot to enable which was enabled in windows php (xampp) that's not on ubuntu?

my .htaccess/logs/boostrap are found here

thanks for reading this and helping out

I assume that root folder of your application is 'admin'. In bootstrap.php you should have:

Kohana::init(array(
    'base_url'      => '/admin',
    'index_file'    => FALSE,
));

Also in your bootstrap.php default route should be last route:

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

Other routes that you add should take place above default route.

To add to digby's note: All class file names and directory names are lowercase.

There are a few little things I noticed but nothing that could explain the problem you are having:

  • Query strings should not be and are not used to route to an action. Use $this->request->query() in controllers to use GET values.
  • Slashes get trimed off the beginning and end of URI's, so the optional / in the commented out 'def' route is useless.
  • The second time defining the kendogrid route overwrites the old one. Not that it really matters since they are the same, so why not remove one?

What controller do you expect to be routed too? Currently it should be Controller_... Hmm... I spy with my little eye a typo! 'susbcribers' instead of 'subscribers'. So currently you will be routed to Controller_Susbcribers::index().

If you want the Controller_Useraccess::index() instead of Controller_Subscribers::index() (assuming you fix the typo) remove the first kendogrid route since both 'kendogrid' and 'default' match an empty URI.

PS. I am assuming you use 3.2

I have same problem with you, my kohana running well on my windows machine. but when i migrate it to Ubuntu I have a problem with routing. This is my bad, i forgot to edit my apache conf. You can look into conf file in /etc/apache2/sites-enabled/000-default

   
Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   allow from all
/Directory>

edit 'AllowOverride None' to 'AllowOverride All' and restart your apache webserver .

Works like magic !!