Php – Codeigniter `No Input File Specified` & `404 Page Not Found` Errors when Live

.htaccesscodeigniter-2codeigniter-urlmod-rewritePHP

I have a website I built on codeiginiter 2.0.1 (My own personal site). I built this application locally using WAMP and it works 100% as it should (Locally). I uploaded this to my live server and I keep getting "404 page not found" error. This error is coming from codeigniter through my Home->Error method, not the server, so code igniter is definitely working.

Here is my routes config. If I change the 404_override to 'Home'. It loads my home controller as it should, but when I go to ANY page I get the 404 page not found.

$route['default_controller'] = 'Home';
$route['404_override'] = 'Home/Error';

I suspect this may have something to do with my .htaccess & Codeigniter config.

// Codeigniter Config.php - Note: My Hosting is with Godaddy. [CGI/FastCGI]
$config['index_page'] = 'index.php?';
// Tried Auto and All others, REQUEST_URI works fastest for me.
$config['uri_protocol'] = 'REQUEST_URI';

My .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L] 

I tried so many links through SO & Google to fix this, the ones I tried repetitively are below.
CodeIgniter 404 Page Not Found, but why?
codeigniter 404 on existing controller
http://codeigniter.com/forums/viewthread/60469/#297477
http://codeigniter.com/wiki/Godaddy_Installaton_Tips
– Amongst many others

I'm sure this has goto do with the htaccess and mod_rewrite, Any Ideas?


Update
If I change the the $route['404_override'] = 'Home/Error' to any of my controllers, they show and work as expected, but for some reason, its always throwing a 404 page.

If I go to: /index.php/home – I get the error No input file specified.

Best Answer

first controllers name should be in lowercase like:
$route['default_controller'] = 'home';

then you might leave in blank the index_page:
$config['index_page'] = '';

finally in .htaccess should be alongside index.php in the base path directory, you might change the last line like:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /home/index.php?$1 [L]

hope it solve

Related Topic