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 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?