php - 错误 : A default route has not been specified in the routing file in CI 3. 0

标签 php codeigniter routes

我已经在我的本地机器上成功地运行了测试网页并且它工作正常!但是当我把它上传到生产服务器(iPage)时,我得到了这个错误:

An Error Was Encountered
Unable to determine what should be displayed. A default route has not been specified in the routing file.

我这里有 .htacess 文件:

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond $1 !^(index\.php|assets|img|bg|robots\.txt)
 RewriteRule ^(.*)$ index.php?/$1 [L] 

在应用程序文件夹之外。

在我的 routes.php 中:

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

在我的 config.php 中:

$config['base_url'] = 'http://example.com/System';
$config['uri_protocol'] = 'REQUEST_URI';
$config['enable_query_strings'] = TRUE;

我在 Controller 文件夹中有 login.php 和 ff 代码:

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

class login extends CI_Controller {
    function __construct() {
        parent::__construct();
        $this->load->model('login_model');
        /* enable session */
        $this->load->library('session');
    }

 public function index()
    {
        if ( ! file_exists(APPPATH.'/views/index.php'))
        {
            /* Whoops, we don't have a page for that! */
               show_404();

        }

        $this->load->view('index'); 
       $this->load->view('templates/footer');   

   }    

是我遗漏了还是做错了什么?

最佳答案

CodeIgniter 3 要求您的以 Ucfirst 方式命名并且文件名必须与类名匹配。

因此,您需要将“login.php”重命名为“Login.php”,并将类声明更改为class Login extends CI_Controller

关于php - 错误 : A default route has not been specified in the routing file in CI 3. 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31933300/

相关文章:

php - 需要使用 PayPal 进行用户注册

php - 代码点火器 : A lot of function in the same controller

php - 使用 Imagick 将每个 PDF 页面保存为图像

java vs. php 以 html 形式使用 post

php - 'Unsupported SSL protocol version' Curl OpenSSL version confusion (paypal api php sdk)

php - 检查输入是否与数组中的当前显示项匹配 php

mysql - Codeigniter 何时从 MYSQL DB 检索数据

php - Laravel Route 传递额外的变量

Angular 子模块子路由不起作用。无法匹配任何路由

ruby-on-rails - rails : possible to restrict a route based on IP address (or range? )