Codeigniter无法识别新添加的控制器

时间:2014-02-28 17:29:02

标签: php apache .htaccess codeigniter

我一直在使用CI很长一段时间。今天我添加了一个名为“gallery”的新控制器,但它没有用。它显示错误“404(找不到页面)错误”。如果您想要查看http://picask.net/gallery,这就是链接。它似乎无法再自动路由到控制器中的默认索引功能。但是很奇怪的是,过去添加并以相同格式编写的其他控制器仍能正常工作(这是此问题中最重要的一点!)例如:http://picask.net/about此链接有效。

我想这可能是因为htaccess文件。但我不确定,因为我在添加新控制器“gallery”时没有更改文件。无论如何,这里是我的htaccess文件的内容,如果它可能是原因:

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteBase /
#RewriteBase /picask/

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> 

#Options +FollowSymLinks
#RewriteEngine on
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f  
#RewriteCond %{REQUEST_FILENAME} !-d  
#RewriteRule ^(.*)$ index.php?/$1 [L] 

这是控制器文件gallery.php(注意:我在互联网上看到一些人有同样的问题,因为他们从现有的控制器复制但忘记更改文件名,但这不是我的情况) :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Gallery extends CI_Controller 
{
    public function index()
    {
          // I commented everything just to make it easier to figure out the problem
          // 

    }
}
?>

'about'控制器的格式相同但有效:

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class About extends CI_Controller
{   
    function index()
    {
        //deleted content
    }
}
?>

和routs.php文件:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = "home";
$route['404_override'] = '';

有人可以告诉我哪里出错吗?非常感谢!

0 个答案:

没有答案
相关问题