开发者

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://localho开发者_JAVA百科st/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? :)


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.


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]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜