Search code examples
codeigniterrouteshttp-status-code-404codeigniter-2

404 page not found in codeigniter 3


I am having 404 when I uploaded the codeigniter to server. I tried every known method and still unable to find the solution My .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');
    }
 }

Solution

  • First with your uri_protocol

    Try This

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

    Instead of

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

    File names must have first letter upper case on CI3 versions same with classes.

    Lloyd.php

    Instead of

    lloyd.php

    With base url all ways good to use / at end also.

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

    Make sure you have the htaccess file on the main directory of your project.