Issue
I've got an MVC project I'm trying to set up on a new computer. I'm using MAMP and codeigniter. For some reason I get a 404 error when I try to go to any controller.
But the weird thing is that the default controller, defined in the routes file seems to work ok.
Here's an example controller:
class Test_controller extends CI_Controller {
public function index(){
echo 'hello';
}
}
When I go to localhost:8888/test_controller
I get 404.
However, adding the following line to my routes.php
...
$route['default_controller']="test_controller";
...and then navigating to localhost:8888
seems to load the controller ok.
Solution
You are missing the .htaccess
, by default CI will need /index.php/
controller to work, to remove the index.php
you can use the HTaccess provided by Codeigniter or this one:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Place this outside the application folder with the name ".htaccess"
Answered By - killstreet
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.