【问题标题】:I get a 404 error not found in CodeIgniter HMVC我在 CodeIgniter HMVC 中找不到 404 错误
【发布时间】:2016-06-21 21:10:42
【问题描述】:

希望有人能帮我解决这个错误,我的项目 HMVC CodeIgniter 3.0 中有以下代码行

config.php

$config['base_url'] = 'http://web.com/project/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';

routes.php

$route['default_controller'] = 'login/home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

.htaccess

RewriteEngine on

RewriteCond $1 !^(index\.php|assets|images|files|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

我的文件夹的根目录如下

project
| application
| | config
| | | config.php
| | | routes.php
| | modules
| | | login
| | | | models
| | | | | ...
| | | | views
| | | | | ...
| | | | controllers
| | | | | home.php
|.htaccess

结果:

404 页面未找到

找不到您请求的页面。

我需要帮助..谢谢!

【问题讨论】:

  • 出现该错误的 URL 是什么?是 CodeIgniter 404,还是浏览器默认的 404?
  • CodeIgniter 自己的,但是如果控制器向我显示默认出现的“欢迎”
  • @Jean_Paul 什么是“CodeIgniter 拥有”?主页是否有效,但其他页面无效,因为这意味着 RewriteEngine 有问题,并且由于您的 .htaccess 文件看起来不错,我会检查它是否已在您 php.ini 中启用。
  • Error 404 is the same CodeIgniter , ini.php has been configured , is hosting on a website, but if I answer the driver that come by default , others not :(
  • @Jean_Paul 我无法理解。你说的是共享主机?你指的是什么司机?是主页“根”网址还是子页面?

标签: codeigniter


【解决方案1】:

改变你的

$config['base_url'] = 'http://web.com/project/';

$config['base_url'] = 'https://web.com/project';

【讨论】:

  • 通常这将是您的基本 URL,带有尾部斜杠:在评论部分\
【解决方案2】:

如果您已经在使用.htaccess,只需删除$config['index_page'] 中的index.php,我的大部分项目都使用codeigniter,我将$config['base_url'] 留空。还要确保您的 project 控制器实际上存在于控制器文件夹中并正确使用 CI 格式。阅读手册了解更多信息。

【讨论】:

    猜你喜欢
    • 2016-03-09
    • 2011-06-02
    • 2016-12-11
    • 1970-01-01
    • 2016-12-06
    • 2015-09-19
    • 2017-05-24
    • 2013-12-28
    • 2015-10-07
    相关资源
    最近更新 更多