【发布时间】:2014-09-19 06:41:58
【问题描述】:
试图在浏览器中调用 controllers/api/v1/ 文件夹中的控制器。它在本地主机上正常工作,但移动到服务器后出现 kohana 错误:
if ( ! class_exists($prefix.$controller))
{
throw HTTP_Exception::factory(404,
'The requested URL :uri was not found on this server.',
array(':uri' => $request->uri()) )->request($request);
}
// Load the controller using reflection
$class = new ReflectionClass($prefix.$controller);
初始化:
Kohana::init(array(
'base_url' => '/',
'index_file' => FALSE,
));
这是我的路线:
Route::set('api', 'api/v1(/<controller>(/<action>(/<id>)))')
->defaults(array(
'directory' => 'api/v1',
'controller' => 'admin',
'action' => 'index',
));
Route::set('subsource', 'api/v1/<controller>(/<id>(/<action>))')
->defaults(array(
'directory' => 'api/v1',
'controller' => 'admin',
'action' => 'index',
));
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
控制器名称以 Controller_Api_V1_ 开头
/controllers/ 文件夹中的控制器工作正常。
【问题讨论】:
标签: php routes kohana subdirectory