你是如何在 url 上面访问的?有可能是重写规则和路由没有匹配上导致的,请下面的正常配置:
# RewriteBase / http://yourdomain/ # RewriteBase /kohana/ http://yourdomain/kohana/
把 kohana 放到子目录中的一个问题
在 .htaccess 中设定 RewriteBase /kohana/,然后在 Bootstrap.php 中有大概如下规则:
Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))')
->defaults(array(
'directory' => 'admin',
'controller' => 'home',
'action' => 'index',
));
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
然后坏掉了,抛出异常:Class controller_kohana does not exist。
其实期许使用的 controller 是 controller_welcome,而去掉 admin 部分的规则后是正常的。
你是如何在 url 上面访问的?有可能是重写规则和路由没有匹配上导致的,请下面的正常配置:
# RewriteBase / http://yourdomain/ # RewriteBase /kohana/ http://yourdomain/kohana/
# RewriteBase /kohana/ http://yourdomain/kohana/
Router 的配置如文中所述。
访问 http://youdomain/kohana/admin 是正常的,访问 http://youdomain/kohana/ 就出问题了。
application/bootstrap.php 文件中是否也作了更改:
Kohana::init(array(
'base_url' => '/kohana/',
'index_file' => FALSE,
));
发表讨论