我仅在服务器环境中遇到此结构的问题:
controllers
-> Controller_home.php
-> folder 1/
-> Controller_1.php
-> Controller_2.php
-> folder 2/
-> Controller_3.php
Controller.home.php
工作正常
Controller_1.php
工作正常
Controller_2.php
工作正常
Controller_3.php
不起作用 - 出现我的自定义 404 页面错误
我使用的是 CodeIgniter 3.0 版本,以前我在每个控制器的首字母要求为大写时遇到了问题。所以我重命名了我所有的控制器和模型文件,以使用第一个字母作为大写。
我认为我现在遇到的问题可能是由于控制器内的文件夹/不是大写的,但不是因为这样。
我再说一遍,该结构适用于本地环境。
编辑:根据要求,我的.htaccess
文件:
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# activate URL rewriting
RewriteEngine on
# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(index'.php|public|robots'.txt)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond $1 !^([^'..]+'.php|robots'.txt)
# but rewrite everything else
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/bmp "access plus 1 month"
</IfModule>
我的Controller_3.php
(实际上是客户控制器)代码:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Customers extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('backend/customers/index');
}
}
?>
编辑 2:我的完整(到目前为止)路由文件:
$route['translate_uri_dashes'] = TRUE;
$route['default_controller'] = 'home/login';
$route['404_override'] = 'home/error';
$route['app/entities/index'] = 'backend/entities/index';
$route['app/suppliers/index'] = 'backend/suppliers/index';
$route['app/administration/customers/index'] = 'backend/administration/customers/index';
经过大量的调试,并在@CodeGodie同事的帮助下,通过给我提示,我最终意识到在将系统/文件夹传输到我的FTP服务器时出现了一些问题。
我再次下载了CodeIgniter 3.0框架,只需复制粘贴系统/文件夹,它就会立即开始工作。