2012-12-07 63 views
1

嗨,我有我的Kohana代码有问题它让我同样的错误,我认为有一个问题htaccess的或引导Kohana中找不到网址

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

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设置为 '/'

回答

0

这个异常被扔,因为没有找到控制器。默认情况下,'/'URI表示调用方法action_index()Controller_Welcome。见bootstrap.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有新的file/class naming conventions
1

请尝试发布大部分bootstrap.php文件。有可能你没有默认的根集。您的文件中

搜索一个代码块,看起来像

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

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

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

4

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

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

它帮助了我。

1

你所看到的是当你还没有set up your environment to run for the first time to use clean urls时抛出的错误。这样做:

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

    RewriteBase /localhost/my/site/

    (请确保您重命名所以它只能叫.htaccess

  2. 进入你的引导程序。php文件并确保Kohana::init有:

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

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

    /application/classes/Controller/Welcome.php

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