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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?