【问题标题】:Codeigniter all urls are being routed to default controllerCodeigniter 所有 url 都被路由到默认控制器
【发布时间】: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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    相关资源
    最近更新 更多