【发布时间】:2013-06-12 12:58:02
【问题描述】:
我希望有人可以就如何解决这个问题给我一个建议。我开发了一个 codeigniter 应用程序并将其上传到了一个 godaddy 子域。它在本地运行良好,但是在ci.site.com 运行它时,所有 url 都被路由到默认控制器。例如,假设我的默认控制器设置为$route['default_controller'] = 'home/index';。如果我去ci.site.com,家庭控制器加载索引方法就好了,但是当去ci.site.com/users/index时,我被路由回home/index,即使url读取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_url 和index_page 配置参数都是正确的,我似乎无法弄清楚。任何建议将不胜感激。
【问题讨论】:
-
route.php怎么样 -
你的意思是
routes.php?我将users/index定义为$route['users/index'] = 'users/index';$route['users'] = 'users/index'; -
我也尝试了每个
uri_protocol选项,结果相同。 -
您的默认控制器应如下所示
$route['default_controller'] = 'home' -
请编辑您的帖子并向我们展示
routes.php,谢谢
标签: php codeigniter .htaccess url