无法加载默认控制器 - 给定的解决方案不起作用

时间:2017-02-05 18:45:15

标签: php codeigniter

我遇到与unable to load your default controller on Codeigniter相同的问题。我正在尝试简单地加载我的网站tripmatcher.herokuapp.com,我在该网址上获得500,并在加载 时收到 'Unable to load your default controller' 消息。

我的主文件夹是application / front,其中有一个名为index.html的文件夹。这被定义为index.php中的主文件夹,如下所示:

/*

 *---------------------------------------------------------------
 * APPLICATION FOLDER NAME
 *---------------------------------------------------------------
 *
 * If you want this front controller to use a different "application"
 * folder then the default one you can set its name here. The folder
 * can also be renamed or relocated anywhere on your server.  If
 * you do, use a full server path. For more info please see the user guide:
 * http://codeigniter.com/user_guide/general/managing_apps.html
 *
 * NO TRAILING SLASH!
 *
 */
    $application_folder = 'application/front';

我也尝试过将/ index指定为root,以及home / index和home / index.html。我正在努力弄清楚我做错了什么。

我的routes.php:

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

2 个答案:

答案 0 :(得分:2)

为什么要更改应用程序文件夹路径?它应该是

$application_folder = 'application';

假设您的控制器名称为 welcome 。然后文件名应为 Welcome.php 。在文件里面

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

}

在路线(application / config / routes.php)

$route['default_controller'] = 'welcome';

答案 1 :(得分:1)

只需使用

$application_folder = 'application'; /* or whatever you want */

然后,当您要配置默认控制器时,可以编辑application/config/routes.php

$route['default_controller'] = 'default_controller'; /* where default controller is the controller what you want be the default */