0

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]
4

1 回答 1

1

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

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

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

RewriteBase /

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

除此之外,Kohana 3.3 还引入了对 PSR-0 的支持。因此,请浏览 APPPATH/classes/ 中的所有文件,并在必要时重命名它们。例如:APPATH/classes/Controller/admin.php应该是APPPATH/classes/Controller/Admin.php

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

于 2013-10-26T13:04:39.153 回答