2

this is killing me

what do i have? CI version: 2.1.4 Modular Extensions - HMVC by wiredesignz a basic codeigniter(hmvc) project that works fine with the setting it has in local server(mamp) with php 5.5.3

my problem after i move the project to public web server i changed the following things. ——application/config/config.php

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

——application/config/database.php

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'newdbusername';
$db['default']['password'] = 'newdbpassword';
$db['default']['database'] = 'newdbname'; 

—-public_html/.htaccess

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]    
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

since my index page will be the index function of ‘home’ module, i have not touched routes.php file in application/config folder. below is the settings for routes.php

$route['default_controller'] = "home";
$route['404_override'] = ''; 

THE PROBLEM whenever try to access http://example.com/ i get the message below

404 Page Not Found The page you requested was not found.

i get same message if i try example.com/home but example.com/welcome still gives welcome to codeigniter page

WHAT IS GOING ON!!!??? why cant i access any of my page from modules?? what have i missed?? is anyone else getting this problem??

ps: my cpanel has php 5.3.27 if that helps

Update:: below is my default controller's index function

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends MX_Controller
{

function __construct() {
parent::__construct();
}
function index()
{
    $this->load->library('recaptcha');
    $data['recaptcha_html'] = $this->recaptcha->recaptcha_get_html();
    $data['view_file'] = "checkmember"; 
    $this->load->module('templates');
    $this->templates->checkinfo();
}

============

UPDATE 2

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     *      http://example.com/index.php/welcome
     *  - or -  
     *      http://example.com/index.php/welcome/index
     *  - or -
     * Since this controller is set as the default controller in 
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see http://codeigniter.com/user_guide/general/urls.html
     */
    public function index()
    {
        $this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
ashish
  • 3,555
  • 1
  • 20
  • 26
  • Missing quote at newdbpassword. – Shomz Feb 03 '14 at 12:40
  • i missed to put quote here... actual file has opening and closing quotes – ashish Feb 03 '14 at 12:45
  • @Shomz do you have any idea whats going with my issue?? – ashish Feb 03 '14 at 13:27
  • Not really, I remember earlier versions of CI (<2.0) had issues with controllers called 'home', but I doubt that's it. What happens when you create a new, empty controller and try to access it? Also, it might help to show your home controller here. – Shomz Feb 03 '14 at 13:29
  • @Shomz I have updated the question with my home controller. this thing works flawlessly on my local machine. Any idea would be appreciated. PS i have tried changing default controller to something else and i still get 404 page – ashish Feb 03 '14 at 13:46
  • No, no, I meant to create a new controller (`class Test extends MX_Controller...`). Indeed, your code looks fine. Any mods in the MX_Controller? – Shomz Feb 03 '14 at 14:58
  • i have tried creating a new controller but no luck... I havent done any mods on MX_contoller @Shomz – ashish Feb 03 '14 at 15:15
  • Hmmm, and would you mind showing the welcome controller? I'm curious about what's different... Is it maybe extending the CI_controller instead? – Shomz Feb 03 '14 at 15:38
  • i have updated question with welcome controller.... it is untouched that comes with CI download. please advise @Shomz – ashish Feb 03 '14 at 15:56
  • Definitely looks like something in the HMVC, that's the only difference. What if you change the home controller to extend the CI one? – Shomz Feb 03 '14 at 16:27
  • I tried extending home controller to CI one but no effect... still getting 404 – ashish Feb 04 '14 at 04:46
  • @Shomz Solved my problem!! check the answer i posted... – ashish Feb 04 '14 at 07:15
  • Nice, I still can't believe that the default controller worked! :) – Shomz Feb 04 '14 at 13:08

4 Answers4

7

I figured the problem was not with HMVC but was with codeigniter version 3.0. When it comes to unix(which was the operating system running on my server), it is case sensitive. So when I tried to access the controller it could'nt find the file because of case sensitivity and a 404 popped out everytime.

My folder structure before was something like :

-application
-->modules
--->users
---->controllers
----->users.php

And the link on which I was getting 404 was www.example.com/users/login

where "users" in the link is controller's name within the "controllers" folder under "modules" folder in my case named as users.php and "login" is the function inside the controller.

All I had to do was to change the case of the first letter of my module and controller name. Now my directory looks like

-application
-->modules
--->Users
---->controllers
----->Users.php

note : capitalized "U" in Users module and Users controller.

And the the url I used to access the users controller was : www.example.com/Users/login

And I was good to go.

Zeeshan Cornelius
  • 308
  • 1
  • 4
  • 15
1

Finally the problem was solved. this was my folder structure in modules folder.

—modules/

—————/home

————————/Controllers——->home.php

————————/Models——->mdl_home.php

————————/Views——->viewfile.php

all i had to do was change the capitalization on “Controllers”, “Models” and “Views” folders and i was back in business.

now the folder structure is like this and its working perfectly

—modules/

—————/home

————————/controllers——->home.php

————————/models——->mdl_home.php

————————/views——->viewfile.php

Ashish

ashish
  • 3,555
  • 1
  • 20
  • 26
  • i too have same issue and my folder name inside module are already in lower case what can be issue, my local machine is windows and production is linux. It also does not work on my macbook. This means there is some error with naming convention which works on windows and not on mac/linux – Umar Adil Jul 26 '14 at 16:07
  • Your module folder name and controller file name should both be in the same case(upper or lower), if they are already also check the calls you are making via url are in the same case as your files are. – Zeeshan Cornelius Sep 28 '15 at 12:25
1

I had the same problem. When I renamed folders "Controllers" and "Views" to lower case, it worked. Linux debian.

enter image description here

Catarina Ferreira
  • 1,824
  • 5
  • 17
  • 26
Celio
  • 11
  • 2
0

I resolve my problem AS follow directory and files structure its working properly. on server side class name and file name should be start with capital letters as below

-modules
---/login
-----/controllers
---------/Login.php
-----/models
---------/Login_model.php
-----/views
---------/login.php
vpgodara
  • 329
  • 2
  • 2