【问题标题】:Codeigniter 404 on live server实时服务器上的 Codeigniter 404
【发布时间】:2015-06-07 08:15:45
【问题描述】:

我正在使用 HMVC 运行 CI 3.0。在我的本地 XAMPP 上一切正常,但在我的 (linux) 实时服务器上,我收到来自 CI 的错误 404 (Page Not Found)。

我有几个小时,尽我所能解决这个问题..没有成功!

这是我现在拥有的:

$route['default_controller'] = 'default';

htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

我的结构:

-应用

--模块

---默认

----控制器

-----Default.php

我的控制器 Default.php:

class Default extends MY_Controller  {

 public function __construct()
 {
     parent::__construct();
 }

 public function index()
 {
     ....
 }
}

CI 错误日志中的错误:

错误 - 2015-04-02 13:15:56 --> 404 页面未找到:../modules/default/controllers//index

..仍然是 404。这有什么问题???

【问题讨论】:

标签: codeigniter


【解决方案1】:

检查所有控制器和库是否以大写开头即欢迎。在您的核心/MY_Controller 中通过 MX_Controller

扩展它

核心/MY_Controller

class MY_Controller extends MX_Controller {}

config/routes.php

$route['default_controller'] = "default/default/index";

hmvc 中的路由需要module-name/controller-name/function

当您从那里下载 hmvc 时,请确保您转到分支并为您的 codeigniter 下载正确的版本“HMVC 默认下载”适用于 codeigniter 2

虽然我认为现在只有 codeigniter hmvc 3 可供下载。 https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads

我在下面的主目录中也使用了 htaccess。您也可以从这里下载更多 htaccess 文件。 http://www.insiderclub.org/ 在下载部分。

Options +FollowSymLinks
Options -Indexes

<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
    Order deny,allow
    Deny from all
</FilesMatch>

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

【讨论】:

    【解决方案2】:

    知道了!

    为了使用 HMVC 进行测试/开发,我将原始文件夹 application/controllers 重命名为 application/controllers_off。 我的控制器位于:

    应用程序/模块/默认/控制器/

    所以我想我可以重命名或删除原始文件夹

    文件夹 application/controllers 为空,但 HMVC 扩展似乎需要此文件夹。所以将其重命名为“控制器”解决了我的问题。

    难以置信!!!

    【讨论】:

    • 永远不要删除“只是认为可以”的内容,除非您对后果不是 100% 清楚。打开机器后,任何相关的事情都可以记住这一点。
    猜你喜欢
    • 2016-05-10
    • 1970-01-01
    • 2018-01-22
    • 1970-01-01
    • 2016-11-13
    • 1970-01-01
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多