【问题标题】:Why I go error_404.php errors in codeigniter when upload to hosting?为什么我在上传到主机时在 codeigniter 中出现 error_404.php 错误?
【发布时间】:2015-01-29 03:32:20
【问题描述】:

当我上传到主机时,我的网站无法正常工作,但它可以在 localhost 中工作。 当我尝试访问 url 时,它总是显示 ERROR - 12-01-14 06:33:25 --> 404 Page Not Found: /index (日志文件),我得到了错误。

这是我的主机用户名和密码 在此处访问控制面板:

  • https://cp.supremecenter300.com
  • 客户 ID:142606
  • 登录:hengsopheak
  • 密码:2142885

    defined('BASEPATH') OR exit('不允许直接脚本访问');

    函数 __autoload($classname) { if (strpos($classname, 'CI_') !== 0) { $文件 = APPPATH 。 '库/' 。 $类名。 '.php'; if (file_exists($file)) { @include_once($file); } } }

    $config['base_url'] = '';

    $config['index_page'] = '';

    $config['uri_protocol'] = 'PATH_INFO';

    $config['url_suffix'] = '';

    $config['language'] = 'english';

    $config['charset'] = 'UTF-8';

    $config['enable_hooks'] = FALSE;

    $config['subclass_prefix'] = 'MY_';

    $config['composer_autoload'] = FALSE;

    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';

    $config['allow_get_array'] = TRUE; $config['enable_query_strings'] = FALSE; $config['controller_trigger'] = 'c'; $config['function_trigger'] = 'm'; $config['directory_trigger'] = 'd'; // 实验性当前未使用

    $config['log_threshold'] = 4;

    $config['log_path'] = '';

    $config['log_file_extension'] = 'php';

    $config['log_date_format'] = 'm-d-y H:i:s';

    $config['error_views_path'] = '应用程序/视图/错误';

    $config['cache_path'] = '';

    $config['encryption_key'] = 'sdfasdfasdfasdfadf';

    $config['sess_driver'] = 'cookie'; $config['sess_valid_drivers'] = array(); $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7720; $config['sess_expire_on_close'] = 假; $config['sess_encrypt_cookie'] = TRUE; $config['sess_use_database'] = 真; $config['sess_table_name'] = 'ci_sessions'; $config['sess_match_ip'] = 真; $config['sess_match_useragent'] = TRUE; $config['sess_time_to_update'] = 300;

    $config['cookie_prefix'] = ''; $config['cookie_domain'] = 'vtrashop.com/'; $config['cookie_path'] = '/'; $config['cookie_secure'] = 假; $config['cookie_httponly'] = FALSE;

和路由器

$route['default_controller'] = 'page';
$route['cat/(:num)'] = 'cat/index/$1/$2/$3';
$route['detail/(:num)'] = 'detail/index/$1/$2';
$route['404_override'] = '';

在 Controller 文件名:page 类名:Page.

<?php

Class Page extends Frontend_controller {

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

    }

    public function index() {

         $this->data['subview'] = 'page';
        $this->load->view('_main_layout', $this->data);
        }
?>

和.htaccess

# Set PHP Time Zone:
#SetEnv TZ America/New_York
<IfModule mod_rewrite.c>

#Option +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond $1 !^(index\.php|pages|video|images|social|style|sliderengine|bar|robots\.text)

RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

</IfModule>

我只收到此消息 消息:include(): 未能打开“application/views/errorshtml/error_404.php”以包含 (include_path='.;c:\php\pear')

我现在该怎么办

【问题讨论】:

  • 从不分享您的托管详细信息从问题中删除
  • 我现在不关心安全性我只想让它工作?
  • 显示此错误是因为您提供了错误的路径,您的路径是 application/views/errors/html/error_404.php
  • 不是这个,我越来越多地改变它,我尝试了 2 周但仍然不行
  • 我的嘘声几乎要了我的命

标签: php .htaccess codeigniter web-config


【解决方案1】:

大多数时候发生此错误是因为文件命名问题。我认为您使用的是 Linux 主机。所以我也遇到了同样的问题,最后我找到了我们不能使用大写字符的文件名的解决方案。

示例

如果我们有一个名为 my_controller 的控制器,文件名应该是这样的 my_controller.php 并且不要使用像这样的 My_Controller.php、myController.php 这样的大写字符作为文件名。

【讨论】:

  • 所以我已经把我所有的控制器都改成小写了吧?
  • $Chamath,CI 我也应该更改 ti ci_controller 怎么样?对
  • 只更改您创建的那些控制器的文件名。
  • 如果你是 CI 的新手,那么将你的 Controller 类重命名为小写应该可以解决这个问题。因为从 localhost 切换到在线托管环境时最有可能出现这种情况。
猜你喜欢
  • 2020-09-05
  • 1970-01-01
  • 1970-01-01
  • 2015-08-29
  • 1970-01-01
  • 2015-10-24
  • 1970-01-01
  • 1970-01-01
  • 2015-04-12
相关资源
最近更新 更多