douqiao7958 2011-04-27 05:53
浏览 55

在CodeIgniter中,始终加载默认控制器

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? :)

  • 写回答

2条回答 默认 最新

  • duanfu3884 2011-04-27 06:48
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思