Obay
Obay

Reputation: 3205

In CodeIgniter, default controller is always loaded

I am trying to migrate my CI 1.7.2 application into 2.0.2. I have gotten to the point where my default controller and page are loaded correct. Yey!

However, the default controller is all that’s ever loaded. Example:

myapp/ -> loads default controller (one)
myapp/one -> loads default controller (one)
myapp/two -> loads default controller (one)
myapp/three -> loads default controller (one)

My .htaccess is:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule> 

My config.php is:

$config['base_url'] = 'http://localhost/myapp/branches/Source%20Code/';
$config['index_page']     = '';
$config['uri_protocol']   = 'QUERY_STRING'; 

By the way, I’ve tried all other possible values for URI PROTOCOL and they give me “The page you requested was not found.”

Finally, my routes.php is:

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

I also tried changing default_controller to "two" and it correctly loads the "two" controller. But when the default_controller is "one" and I type in "myapp/two" in the address bar, it still loads "one"

What am I missing? :)

Upvotes: 0

Views: 2913

Answers (2)

Angelin Nadar
Angelin Nadar

Reputation: 9300

I think uri_protocol => 'PATH_INFO' is not supported

So, change trying to

$config['uri_protocol'] = 'QUERY_STRING'; // application/config/config.php

then, in your , .htaccess change the

RewriteRule (.*) index.php/$1 [L]

to

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

Upvotes: 0

tgriesser
tgriesser

Reputation: 2808

Sounds like an htaccess problem. Try changing your mod rewrite to this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /myapp/index.php/$1 [L]
</IfModule>

and then change $config['uri_protocol'] to AUTO.

Upvotes: 2

Related Questions