控制器无法在CodeIgniter中打开

时间:2012-11-14 20:46:42

标签: .htaccess codeigniter controller

我在CodeIgniter应用程序中有三个控制器 - ilogintest

所有控制器都与/APP/index.php/路径完美配合 - 我可以打开/APP/index.php/i/APP/index.php/login/APP/index.php/test

控制器ilogin也可以在没有index.php的情况下工作 - /APP/i/APP/login(我有一个修改过的.htaccess文件)。< / p>

如果没有test,控制器index.php无效 - 我打开/APP/test时收到404错误。

i是默认控制器,但login不是默认控制器,它可以正常工作(我认为这可能是问题)。

当我添加第4个控制器时,如果没有index.php,它也无效。

它变得更加奇怪 - 有时我可以打开/APP/test/some_function(有时我不能),然后我甚至可以打开/APP/test。但是我不能这样再打开它。 index.php方式始终有效。 Test控制器有一个非常简单的代码......

所以我的问题是这里可能出现什么问题,如何在没有index.php的情况下使我的控制器可以访问?

非常感谢你的帮助。

下面是我的.htaccess文件,我认为问题可能存在:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /APP/

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>

1 个答案:

答案 0 :(得分:0)

由于@w0rldart的建议,我现在明白了问题所在。

实际上,当您在没有index.php文件的情况下访问控制器时,主应用程序文件夹会区分大小写(在我的问题中为APP)。

由于我有一个更长的应用程序文件夹名称,并且它有大小写字母,我只是在错误的情况下输入了一个字母。对于默认控制器,无关紧要,通过案例正确的链接访问其他控制器。

由于test被直接访问,这个错误的案例给了我404错误。

通过index.php路径,主应用程序文件夹的大小写无关紧要。