我已经在我的本地机器上成功地运行了测试网页并且它工作正常!但是当我把它上传到生产服务器(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/