doubiao7410 2013-10-26 09:14
浏览 34
已采纳

部署Kohana 3.3时出现错误500

I have been Googling all over for a solution or something that could direct me to a solution for deploying my Kohana 3.3 site but to no avail.

I am confused on on how make the routing work in Kohana, I left the default route in my bootstrap.php file intact. Here:

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

I'm using a free web hosting and sub-domain and here's my URL: http://atosoft.neq3.com/. And that outputs "hello, world" just fine, with the route above.

But when I want to go to my admin page I get an ERROR 500 here: http://atosoft.neq3.com/admin. How do I set my route to make this work for all controllers?

I do not have sub directories in my Controllers and Models, just in my Views.

Here's my folder structure:

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

Controller/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]
  • 写回答

1条回答 默认 最新

  • doulianxing4015 2013-10-26 13:04
    关注

    Your RewriteBase is wrong. This is from the Knowledge Base:

    Do you support search engine friendly URLs ?

    Yes, search engine friendly URLS are supported, but there is one important thing you must know: We use virtual user directory paths, so you can get error when trying to setup search engine friendly URLs or trying to pass virtual directory names to PHP scripts. If can be fixed very easy. Edit your .htaccess file and add this line at the top of the file or before the first rewrite rule:

    RewriteBase /

    Note: if your script is installed on some directory, for example /forum, you have to place RewriteBase /forum/ line to the .htaccess file (.htaccess file must be also located in /forum directory)

    Besides that Kohana 3.3 also introduced support for PSR-0. So go through all your files in APPPATH/classes/ and rename them if necessary. For example: APPATH/classes/Controller/admin.php should be APPPATH/classes/Controller/Admin.php.

    That should be it. If your kohana folder is currently inside the /public_html folder you might want to do something about that. It's a good idea to put as many files outside of the web root when possible.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败