CodeIgniter route not working CodeIgniter route not working codeigniter codeigniter

CodeIgniter route not working


You have to create the .htaccess file in your app.

DirectoryIndex index.phpRewriteEngine onRewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ ./index.php/$1 [L,QSA] 

Please paste this code in your .htaccess file.


LoneWolfPR hit the nail on the head with his comment, you are using FastCGI which requires a different htaccess.

Can you try using this one?

https://raw.github.com/pyrocms/pyrocms/develop/.htaccess

I am tempted to propose we add it into CodeIgniter 2.1-dev to save this question coming up 15 times a day. Let me know if it works or fails.


Listen, this is the stupidest answer ever, but this is my experience with the similar situation - that just happened. I was helpless, but it started working - here's how.

I have one controller, caller ReadController.php (class is called the same).Route was the same:

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

Calling it with www.martinjovanovic.com/DSi1.5-v01/index.php/ReadController/ - worked.But calling it with just martinjovanovic.com/DSi1.5-v01/ just wouldn't work at all.

Base URL was that of my domain and folder: wwww.martinjovanovic.com/DSi1.5-v01/

No changes to htaccess whatsoever, I left it default (Deny from all).

  1. I switched default controller back to welcome.php.
  2. Made a copy, called it welcome2.php. Class renamed accordingly.
  3. Changed routes to welcome2. It worked. Same welcome screen.
  4. Changed index() inside welcome2.php to some echo('something'). It worked.
  5. Renamed welcome2.php to read.php, class accordingly. Changed it in routes. It worked.
  6. Copy-pasted entire code from original ReadController.php into read.php. It worked.

That was it. Same thing started working.

The only difference between the original ReadController.php and the new read.php was in the first line. In my new read.php I kept the first line that was actually missing in the old ReadController.php (my developer ommited it, I guess):

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

This was immediately after the opening php tag.That was the only difference. I don't get why it made such difference. Maybe it's not about it at all. Nontheless, it worked.

And the moral of this story is: I started from what worked in the first place, and kept slowly changing it towards what I need, until it worked...