Welcome Guest, Not a member yet? Register   Sign In
CI routing - cannot make it work
#1

Hi friends,

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

My controller:

Code:
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:

Code:
$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.
Reply
#2

PHP Code:
$config['index_page'] = ''

./application/config/config.php

Set that and use a .htaccess file to remove the index.php

Code:
DirectoryIndex index.php

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Give that a try.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Thank you InsiteFX,

I decided not to change $config['index_page'].

Therefore the RewriteRule in my .htaccess looks so:
RewriteRule ^(.*)$ index.php/$1
Reply




Theme © iAndrew 2016 - Forum software by © MyBB