【问题标题】:Kohana subdirectory controllers (The requested URL :uri was not found on this server.)Kohana 子目录控制器(在此服务器上找不到请求的 URL:uri。)
【发布时间】: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


    【解决方案1】:

    如果我理解你,你需要一个新的外部请求。以下是文档:Requests

    【讨论】:

    • 我正在尝试在浏览器中调用控制器
    • 如果你的服务器是linux,文件名是否区分大小写?
    猜你喜欢
    • 2014-11-18
    • 2014-03-26
    • 1970-01-01
    • 2017-03-21
    • 2010-10-16
    • 1970-01-01
    • 2014-03-05
    • 2018-05-14
    • 2017-12-26
    相关资源
    最近更新 更多