0

I am new to code igniter and have the following setup in my project files

Models:

Model1

Model2

Controller:

Controller1 [which has only index method]

Controller2 [which has index method of its own]

View:

Views/MyFolder1/index.php [which is view for Controller1]

Views/MyFolder2/index.php [which is view for Controller2]

Routes.php has following code

$route['MyFolder1'] = 'Controller1/index'; // Route to Controller 1 index 
$route['MyFolder2'] = 'Controller2/index'; // Route to Controller 2 index
$route['default_controller'] = 'Controller1';

config.php has

$config['base_url'] = 'http://localhost/projectname';

When I try to call http://localhost/projectname/Controller2/index.php or http://localhost/Controller2 I keep getting Error 404 Page not found . Can you please help resolve this problem ?

Thanks

NaN
  • 948
  • 2
  • 11
  • 23

2 Answers2

2

Add index.php before controller name, Like localhost/projectName/index.php/Controller2

to fix that follow this answer

CodeIgniter removing index.php from url

Community
  • 1
  • 1
0

You should call it as http://localhost/projectname/MyFolder2

The key of the $routes you used is the url you should open.

rmondesilva
  • 1,502
  • 1
  • 11
  • 23
  • Hello, Thanks for your reply. I have tried entering http://localhost/projectname/MyFolder2 and http://localhost/MyFolder2 which always gives me 404 page. However if I use http://localhost/projectname/MyFolder1 or http://localhost/projectname/ it fallback to the Controller1 and displays the page. Not really sure whats going on here with calling Controller2. – NaN Jul 26 '16 at 06:25
  • Try to look if there is a duplicate of `MyFolder2` route... routes that has `(:any)` at first segment of url could be the problem too. – rmondesilva Jul 26 '16 at 06:28
  • Nope, I am pretty sure that there are no duplicate names involved and have included what my Routes.php and other project files look like in the question. – NaN Jul 26 '16 at 06:34