首页 文章

HMVC codeigniter适用于本地服务器,但不适用于Web服务器

提问于
浏览
2

这是在杀我

我有什么? CI版本:2.1.4模块化扩展 - HMVC by wiredesignz一个基本的codeigniter(hmvc)项目,可以在本地服务器(mamp)中使用php 5.5.3正常工作

我将项目移动到公共Web服务器后我的问题我改变了以下的事情 . --application /配置/ config.php中

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

--application /配置/ database.php中

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'newdbusername';
$db['default']['password'] = 'newdbpassword';
$db['default']['database'] = 'newdbname';

--public_html /的.htaccess

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]    
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

因为我的索引页面将是'home'模块的索引函数,所以我没有触及application / config文件夹中的routes.php文件 . 下面是routes.php的设置

$route['default_controller'] = "home";
$route['404_override'] = '';

问题无论何时尝试访问http://example.com/我都会收到以下消息

找不到404页面未找到您请求的页面 .

如果我尝试example.com/home,我会得到相同的消息但是example.com/welcome仍然欢迎使用codeigniter页面

到底是怎么回事!!!???为什么我无法从模块访问我的任何页面?我错过了什么?是其他人得到这个问题?

ps:如果有帮助,我的cpanel有php 5.3.27

Update :: below是我的默认控制器的索引函数

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

class Home extends MX_Controller
{

function __construct() {
parent::__construct();
}
function index()
{
    $this->load->library('recaptcha');
    $data['recaptcha_html'] = $this->recaptcha->recaptcha_get_html();
    $data['view_file'] = "checkmember"; 
    $this->load->module('templates');
    $this->templates->checkinfo();
}

============

更新2

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

class Welcome extends CI_Controller {

    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     *      http://example.com/index.php/welcome
     *  - or -  
     *      http://example.com/index.php/welcome/index
     *  - or -
     * Since this controller is set as the default controller in 
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see http://codeigniter.com/user_guide/general/urls.html
     */
    public function index()
    {
        $this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

4 回答

  • 0

    我认为问题不在于HMVC,而在于codeigniter 3.0版 . 说到unix(在我的服务器上运行的操作系统),它区分大小写 . 因此,当我尝试访问控制器时,它无法找到该文件,因为区分大小写并且每次都会弹出404 .

    我以前的文件夹结构是这样的:

    -application
    -->modules
    --->users
    ---->controllers
    ----->users.php
    

    我获得404的链接是www.example.com/users/login

    链接中的“用户”是控制器的名称,位于“modules”文件夹下的“controllers”文件夹中,在我的情况下命名为users.php,“login”是控制器内部的功能 .

    我所要做的就是更改模块和控制器名称的第一个字母的大小写 . 现在我的目录看起来像

    -application
    -->modules
    --->Users
    ---->controllers
    ----->Users.php
    

    注意:Users模块和Users控制器中的大写“U” .

    我用来访问用户控制器的网址是:www.example.com/Users/login

    我很高兴去 .

  • 1

    最后问题解决了 . 这是我在modules文件夹中的文件夹结构 .

    • 模块/

      • -/家

    -------- /控制器---> home.php

    -------- /型号---> mdl_home.php

    -------- /浏览次数---> viewfile.php

    我所要做的就是更改“控制器”,“模型”和“视图”文件夹的大小写,然后我重新开始营业 .

    现在文件夹结构是这样的,它的工作完美

    • 模块/

      • -/家

    -------- /控制器---> home.php

    -------- /型号---> mdl_home.php

    -------- /视图---> viewfile.php

    阿希什

  • 7

    我有同样的问题 . 当我将文件夹“控制器”和“视图”重命名为小写时,它工作 . Linux debian .

    enter image description here

  • 1

    我解决了我的问题AS跟随目录和文件结构它正常工作 . 在服务器端类名和文件名应以大写字母开头,如下所示

    -modules
    ---/login
    -----/controllers
    ---------/Login.php
    -----/models
    ---------/Login_model.php
    -----/views
    ---------/login.php
    

相关问题