1

嗨,我的 kohana 代码有问题,它给了我同样的错误,我认为 htaccess 或引导程序有问题

它安装在我的根目录中,而不是作为子文件夹。

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

SYSPATH/classes/Kohana/Request/Client/Internal.php [ 79 ]

74          if ( ! class_exists($prefix.$controller))
75          {
76              throw HTTP_Exception::factory(404,
77                  'The requested URL :uri was not found on this server.',
78                  array(':uri' => $request->uri())
79              )->request($request);
80          }
81 
82          // Load the controller using reflection
83          $class = new ReflectionClass($prefix.$controller);
84 

    SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal->execute_request(arguments)

    SYSPATH/classes/Kohana/Request.php [ 990 ] » Kohana_Request_Client->execute(arguments)

    DOCROOT/index.php [ 109 ] » Kohana_Request->execute() 

这是我的 htaccess 代码

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

#-SetEnv KOHANA_ENV "production"

在引导程序中,我将 site_url 设置为“/”

4

4 回答 4

4

当我将 kohana 从 localhost 移动到 linux 托管时,我遇到了同样的问题。

尝试用大写字母重命名控制器文件。在引导路线中保留小写字母。

它帮助了我。

于 2013-03-11T21:12:34.403 回答
1

请尝试尽可能多地发布 bootstrap.php 文件。您可能没有默认的根集。

在文件中搜索看起来像的代码块

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

关键字是Route::set('default', '(<controller>(/<action>(/<id>)))')

您的应用程序托管在哪里?它是在 www 上还是在 www 的子文件夹中?

于 2012-12-12T18:33:45.163 回答
1

您看到的是当您没有将环境设置为第一次运行以使用 clean urls时引发的错误。做这个:

  1. 进入您的.htaccess文件并设置正确的路径,RewriteBase 如果您的本地主机路径 where localhost/my/site,您的 htaccess 应该是:

    RewriteBase /localhost/my/site/

    (确保重命名文件,使其仅被调用.htaccess

  2. 进入你的 bootstrap.php 文件并确保Kohana::init有:

    'base_url' => '/localhost/my/site/'在它的数组中。

  3. /application/classes/Controller/目录中,添加您的控制器文件名,使第一个字母为大写(即Welcome.php),在控制器中,确保您的控制器内容正确写入。

    /application/classes/Controller/Welcome.php

这是解决问题的良好开端。

于 2013-07-05T18:41:53.230 回答
0

由于找不到控制器,因此引发了此异常。默认情况下,'/' URI 表示调用action_index(). Controller_Welcomebootstrap.phpRoute::set('default', ...)

我认为,可能有以下原因之一:

  1. 您有默认路线,并application/classes/Controller/Welcome.php已被删除。
  2. 在将 Kohana 版本升级到 v3.3 时,您没有将application文件夹替换为新文件夹。所以,你有application/classes/controller/welcome.php而不是application/classes/Controller/Welcome.php.
  3. 您已使用不存在的控制器更改了默认路由。请注意,Kohana v3.3 具有新的文件/类命名约定
于 2012-12-07T18:15:04.987 回答