【问题标题】:Error 500 in deploying Kohana 3.3部署 Kohana 3.3 时出现错误 500
【发布时间】:2013-10-26 09:14:37
【问题描述】:

我一直在谷歌上搜索解决方案或可以将我引导到部署我的 Kohana 3.3 站点的解决方案,但无济于事。

我对如何在 Kohana 中进行路由工作感到困惑,我将 bootstrap.php 文件中的默认路由保持不变。这里:

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

我正在使用免费的网络托管和子域,这是我的 URL:http://atosoft.neq3.com/。上面的路线输出“你好,世界”就好了。

但是当我想去我的管理页面时,我在这里得到一个错误 500:http://atosoft.neq3.com/admin。如何设置我的路线以使所有控制器都可以使用?

我的控制器和模型中没有子目录,只是在我的视图中。

这是我的文件夹结构:

/Controller
   - Admin.php
   - Courses.php
   - Exams.php
   - Questions.php
   - Semester.php
   - User.php
   - Welcome.php

控制器/admin.php

class Controller_Admin extends Controller_Template {

    public $template = 'admin_template';

    public function action_index() {
        // User authentication
        $user = Auth::instance()->get_user();

        if(Auth::instance()->logged_in()) {
            // Display Dashboard here
            $dashboard = View::factory('admin/index');
            $this->template->user = $user;
            $this->template->content = $dashboard;
        } else {
            HTTP::redirect('user/login');
        }
    }
}

.htaccess

    # Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /atosoft.neq3.com/

# 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]
RewriteRule ^(application|modules|system)/ - [F,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]
RewriteRule .* index.php [PT]

【问题讨论】:

  • 您需要找出通用“500”错误的实际含义 - 它会在您的日志文件中。
  • 我查看了 Kohana 的 LOG 文件夹,但其中没有任何内容可以解释问题,也没有任何记录在当前日期。
  • 试试你的 Apache/PHP 日志:)
  • 日志是否可能存储在服务器的其他位置?
  • 好的,我刚才试过了,免费服务不允许我访问日志

标签: php routes kohana-3


【解决方案1】:

您的 RewriteBase 错误。这来自知识库:

你们支持搜索引擎友好的 URL 吗?

是的,支持搜索引擎友好的 URL,但有一个 您必须知道的重要事情:我们使用虚拟用户目录路径,所以 尝试设置搜索引擎友好的 URL 或 试图将虚拟目录名称传递给 PHP 脚本。如果可以修复 很容易。编辑您的 .htaccess 文件并在顶部添加这一行 文件或第一个重写规则之前:

重写基础/

注意:如果您的脚本安装在某个目录中,例如 /forum,你必须将 RewriteBase /forum/ 行放到 .htaccess 文件(.htaccess 文件也必须位于 /forum 目录中)

除了Kohana 3.3 also introduced support for PSR-0. 之外,请检查 APPPATH/classes/ 中的所有文件,并在必要时重命名它们。例如:APPATH/classes/Controller/admin.php 应该是 APPPATH/classes/Controller/Admin.php

应该是这样的。如果您的 kohana 文件夹当前位于 /public_html 文件夹中,您可能需要对此做一些事情。尽可能将尽可能多的文件放在 Web 根目录之外是个好主意。

【讨论】:

  • 是的,我已经仔细遵循 PSR-0 支持,我将根目录中的 .htaccess 文件替换为 example.htaccess 中的文件,现在我得到了 Kohana_HTTP_Exception [404]:在此服务器上未找到请求的 URL 管理员。我是否还需要将 BOOTSTRAP 中的 base_url 从我的域更改为 / ?
  • 好的,我快到了@Darsstar !!现在,它无法识别 = url:base() ?> 它说 ErrorException [ Fatal Error ]: Class 'url' not found
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-09
  • 1970-01-01
  • 2019-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多