Вопрос

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]
Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top