Search code examples
codeigniterlivebluehost

Trouble hosting with CodeIgniter


I am a CI newbie. All this time i have been doing my recent projects on my localhost. I chose CodeIgniter and Doctrine as my database framework.

My local host specs are:

Windows 7 Wampserver 2.0

I also have rewrite_module enabled in my apache.

Right from the beginning everything was working fine with CI and Doctrine on my localhost. I managed to finish my project and was happily waiting to port my first project live and uploaded it to a subdirectory of my bluehost account.

Before transferring the files i changed the config.php and the database.php by filling the required values.

But after i uploaded my files(along with the .htaccess) to my hosting solution provider i could see nothing but the 404 error (This is from codeigniter class and not my hosting solutions page). I keep getting this. I tried multiple options but i am not able to figure what this is all about. I am sure the index.php is getting called and when it tries to route to the default controller (which is 'home' in my case) it fails for some reason.

The directory structure in my localhost

PathtoWamp->www->mysitefolder

The directory structure in my live site

public_html(this is my root folder)->mysitefolder

I could also see that rewrite_module has been enabled with my live server (Thats wat my hosting solution bluehost says and i guess this is true)

Since i am very well past the deadline, i am wondering for a solution. Kindly do let me know if any of you guys have any idea.

Thanks in advance.

Regards, Ashok Srinivasan.


Solution

  • I found out the root of the problem. All this time it was not the .htaccess, not httpd.conf and not bluehost, it was not god not anyone but the real culprit was Mr.CodeIgniter.

    If you look at the Router.php located inside system/libraries then you will find a line at number 88 where

    $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
    

    if you notice at the end of the ternary they are forcing a strtolower operation on the controller name. I removed that method and simply let the original name be used at this point by changing the line to this.

    $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : $this->routes['default_controller'];
    

    Ok but what is the big deal here? Yes this makes a lot of sense right now. My local server was wamp installed on Windows and my production server was hosted on an Unix box. Since it is very well known that Windows is a soft guy who does not mind much about case sensitivity but Unix is very particular on the contrary.

    The controller names in my project were all in Capitalized mode, the real issue arised from here. Also i went to my routes.php lying in the application/config where i rectified issues of this perspective.

    Finally i am able to host my site now. Thanks to all who had put their heads into this after reading my question.

    Regards,

    Ashok Srinivasan.