0

I've done small project using Codeigniter. It was running fine in localhost(xampp server), but after uploading in remote server "404 Page Not Found" error is showing. I can't find where I've done a mistake. I'm using the MX Modular extension & Codeigniter version 2.1.2

config.php

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

route.php

$route['default_controller'] = "frontend";

.htaccess (root folder)

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

Application -> Modules -> Frontend -> controllers, models, views

Application -> Modules -> Admin -> controllers, models, views

frontend.php (controller)

class Frontend extends MY_Controller{   
 function __construct(){
    parent::__construct();  
}

function index(){       
    $data['main_content'] = 'frontend';
    $this->load->view('page', $data);
} }

Please help me to get out of this problem. Thanks in advance

Niroj
  • 23
  • 2
  • 8
  • On MY_Controller to you extend MX_Controller like `class MY_Controller extends MX_Controller {}` and file name MY_Controller.php –  Dec 24 '15 at 22:23
  • Your route should be `$route['default_controller'] = "module_name/controller_name/function";` the function could be index etc –  Dec 24 '15 at 22:26
  • Also in base url all ways good to end with / like `$config['base_url'] = 'http://example.com/projectname/';` –  Dec 24 '15 at 22:27
  • If you do not have a MY_Controller the also just extend the controller like `class Frontend extends MX_Controller {}` file name Frontend.php –  Dec 24 '15 at 22:31
  • I tried all possible options still it's not working. Do I need to change anything in .htaccess file? Its running well in local server but after uploading in remote server "404 error". I starting with (https://github.com/degt/Codeigniter-HMVC-example) this code. – Niroj Dec 25 '15 at 09:10

1 Answers1

0

All Module Folders and Classes must have their first letter to be capitalized.

project
---applications
-----modules
-------Somemodule
---------controller
-----------Somemodule.php
---------model
------------Mdl_somemodule.php
---------views

When you call any module function it should be

Modules::run('Somemodule/somefuntion');

Basically the controller name and module folder name in all aspects must start with a capital letter.

Compulsory from codeigniter 3.0 anyways.

if this convention is not followed in a LAMP (Linux) server it throws a 404 Error, though it works fine in a WAMP(Windows) server. Reason being in linux file names are case sensitive.

**For Ex: $route['default_controller'] = "frontend";

Should be

$route['default_controller'] = "Frontend";**

Genocide_Hoax
  • 843
  • 2
  • 18
  • 42
  • I appreciate your help but still the problem isn't solved. mysite.com/index.php/welcome is running successfully but the **frontend** module isn't running. I have started using the modular extension https://github.com/degt/Codeigniter-HMVC-example . Can you please check it once whats wrong in this. I tried uploading the zip file downloaded from the link above, It doesn't run in server & shows **404 Page Not Found** error – Niroj Dec 29 '15 at 13:25