在codeigniter 3中找不到404页面

时间:2015-11-19 09:44:04

标签: codeigniter routes http-status-code-404 codeigniter-2

当我将codeigniter上传到服务器时,我有404。我尝试了所有已知的方法,仍然无法找到解决方案 我的.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

的config.php

$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';

routes.php文件

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

Controller lloyd.php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class Lloyd extends CI_Controller{
    public function __construct() {
        parent::__construct();
    }

    public function index()
    {       
        $theme = $this->aauth->get_system_var("theme");
        $this->load->view($theme . '/home');
    }
 }

1 个答案:

答案 0 :(得分:2)

首先使用您的uri_protocol

试一下

$config['uri_protocol'] = 'REQUEST_URI';

而不是

$config['uri_protocol'] = 'QUERY_STRING';

文件名必须在CI3版本上具有与类相同的首字母大写。

  

Lloyd.php

而不是

  

lloyd.php

使用基本网址最终也可以使用 /

  

$config['base_url'] = 'http://example.com/';

确保项目主目录中有htaccess文件。