Codeigniter所有URL都被路由到默认控制器

时间:2013-06-16 11:31:58

标签: php codeigniter .htaccess url

我希望有人可以就如何解决这个问题给我一个建议。我开发了一个codeigniter应用程序,并将其上传到godaddy子域。它在本地完美运行,但是当在ci.site.com运行时,所有URL都被路由到默认控制器。例如,假设我的默认控制器设置为$route['default_controller'] = 'home/index';。如果我转到ci.site.com,家庭控制器就可以正常加载索引方法,但是当转到ci.site.com/users/index时,即使网址为home/index,我也会返回ci.site.com/users/index }。

这就是我/.htaccess的样子,CI应用和.htaccess位于文档根目录中:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

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

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

我已经部署了多个CI应用,但从未遇到过这个问题。我的base_urlindex_page配置参数都是正确的,我似乎无法弄明白。任何建议都会非常感激。

1 个答案:

答案 0 :(得分:0)

我刚碰到这个。您现在使用的服务器可能没有启用模块mod_rewrite。因此,IfModule!mod_rewrite.c为TRUE。