CodeIgniter项目不能在基于Linux的远程服务器上工作

我在Windows XAMPP上使用CodeIgniter开发了一个项目。 但在基于Linux的远程服务器上不起作用。

我得到的错误:

无法加载请求的文件:home.php

控制器: home.php:

public function index(){ $this->load->view('home'); } 

.htaccess

 RewriteEngine on RewriteCond $1 !^(index\\.php|resources|robots\\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

在codeIgniter 3 +版本的几个检查,如果下面的错误。


  • 找不到错误404页面
  • 无法加载请求的文件

先检查一下。

  • 确保您的文件名只有第一个字母大写
  • 确保你的班名只有第一个字母大写
  • 这也适用于模型。

警告:有些时候,即使小写字母可能在某些本地主机的某些其他操作系统上工作,但是当文件或类是小写字母时,可能会导致错误,但每个人可能都不一样。

调节器

文件名: Home.php

 <?php class Home extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('model_example'); } public function index(){ // $data['results'] = $this->model_example->get_results(); $this->load->view('home'); } } 

视图的文件夹结构

 application application > views > home.php 

楷模

文件名称: Model_example.php

 <?php class Model_example extends CI_Model { public function get_results() { // Some Code Here. } } 

在你的config.php

 $config['base_url'] = 'http://localhost/your_project_name/'; 

而不是直接上传codeigniter网站,你应该可以使用像Putty( http://www.putty.org/ )这样的软件来通过脚本安装一个新版本的Codeigniter,然后把你网站的文件添加到安装中。

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html

用于安装新版CI的脚本将根据您所使用的Linux平台而有所不同。 wget是用于Ubuntu的。