0
votes

I am with CI a couple of days only. Previous experience - .NET C#.

My controller:

class Project extends CI_Controller {
    public function __construct() { parent::__construct(); }

    public function index() {
        echo 'To be or not to be?';
    }
}

The file name /application/config/controllers/Project.php

The routes.php:

$route['default_controller'] = 'home';
$route['project'] = 'project';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

The route for the default_controller works, no problem. $route['project'] returns 'Object not found', 404. The route's position in the list does not change anything. If I use http://my-site.com/index.php/project - this works fine.

Should I use .htaccess file? I did not think that it is an obligatory condition.

Where am I wrong?

Thank you in advance.

1
Using .htaccess is not obligatory if you are willing to accept URLs like the one that "works fine". Also, the line $route['project'] = 'project'; is not necessary. You only need to use routes when you want to deviate from the CI convention of example.com/class/function/id/. - DFriend
Thank you very much, I got it. - YuryN
htaccess is not obligatory but its just one small file and is a big improvement. also make sure you have filled in the base_url value in the application/config/config.php file . and do the tutorial in the codeigniter manual, it will save you a lot of time. - cartalot
List line on page says "The reserved routes must come before any wildcard or regular expression routes." - Tpojka

1 Answers

0
votes

In application/config

Change:

$config['index_page'] = 'index.php';

to:

$config['index_page'] = '';