[英]Error 500 in deploying Kohana 3.3
我一直在搜寻Google解决方案,或者可以将我定向到用于部署Kohana 3.3站点的解决方案,但无济于事。
我对如何在Kohana中使用路由感到困惑,我在bootstrap.php文件中保留了默认路由。 这里:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
我正在使用免费的虚拟主机和子域,这是我的URL: http : //atosoft.neq3.com/ 。 上面的路线可以很好地输出“你好,世界”。
但是,当我想进入管理页面时,会在这里收到错误500: http : //atosoft.neq3.com/admin 。 如何设置路由以使所有控制器都能正常工作?
我的控制器和模型中没有子目录,只有视图中没有。
这是我的文件夹结构:
/Controller
- Admin.php
- Courses.php
- Exams.php
- Questions.php
- Semester.php
- User.php
- Welcome.php
控制器/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]
您的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
文件夹中,则可能需要对此做一些事情。 最好在网络根目录之外放置尽可能多的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.