HMVC Codeigniter在本地服务器上有效,但在Web服务器上无效 [英] HMVC codeigniter works on local server but not on web server

查看:149
本文介绍了HMVC Codeigniter在本地服务器上有效,但在Web服务器上无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这杀死了我

我有什么?
CI版本:2.1.4
模块化扩展-HMVC由wiredesignz
a基本codeigniter(hmvc)项目,可以很好地与php 5.5.3在本地服务器(mamp)中的设置进行配合

what do i have? CI version: 2.1.4 Modular Extensions - HMVC by wiredesignz a basic codeigniter(hmvc) project that works fine with the setting it has in local server(mamp) with php 5.5.3

我的问题
将项目移至公共Web服务器后,我更改了以下内容。
-application / config / config.php

my problem after i move the project to public web server i changed the following things. ——application/config/config.php

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

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

-application / config / database.php

——application/config/database.php

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

-public_html / .htaccess

—-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

因为我的索引页面将成为主页模块的索引功能,所以我没有触摸application / config文件夹中的routes.php文件。以下是routes.php

since my index page will be the index function of ‘home’ module, i have not touched routes.php file in application/config folder. below is the settings for routes.php

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

每当尝试访问。 com / rel = nofollow> http://example.com/ 我收到以下消息

THE PROBLEM whenever try to access http://example.com/ i get the message below

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

404 Page Not Found The page you requested was not found.

如果我尝试example.com/home
,我也会收到相同的消息,但是example.com/welcome仍然欢迎您访问codeigniter页面

i get same message if i try example.com/home but example.com/welcome still gives welcome to codeigniter page

发生了什么!!?
为什么我不能从模块访问我的任何页面?
我错过了什么?
是别人遇到这个问题吗?

WHAT IS GOING ON!!!??? why cant i access any of my page from modules?? what have i missed?? is anyone else getting this problem??

ps:我的cpanel使用php 5.3.27(如果有帮助)

ps: my cpanel has php 5.3.27 if that helps

更新::下面的
是我的默认控制器的索引函数

Update:: below is my default controller's index function

<?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();
}

===========

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

<?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 */


推荐答案

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

Finally the problem was solved. this was my folder structure in modules folder.

-modules /

—modules/

———— -/ home

—————/home

———————— / Controllers ---> home.php

————————/Controllers——->home.php

———————— /模型——-> mdl_home.php

————————/Models——->mdl_home.php

———————— / Views ——-> viewfile.php

————————/Views——->viewfile.php

我要做的就是更改 Controllers, Models和 Views文件夹的大小写,然后我又恢复了业务。

all i had to do was change the capitalization on "Controllers", "Models" and "Views" folders and i was back in business.

现在文件夹结构是这样的,并且可以正常工作

now the folder structure is like this and its working perfectly

—modules /

—modules/

—————— / home

—————/home

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

————————/controllers——->home.php

—————— / models ——-> mdl_home.php

————————/models——->mdl_home.php

—————— // views—— -> viewfile.php

————————/views——->viewfile.php

Ashish

这篇关于HMVC Codeigniter在本地服务器上有效,但在Web服务器上无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆