编程语言
首页 > 编程语言> > php – HMVC codeigniter在本地服务器上运行,但在Web服务器上运行

php – HMVC codeigniter在本地服务器上运行,但在Web服务器上运行

作者:互联网

这是在杀我

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

我的问题
在我将项目移动到公共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

更新::
下面是我的默认控制器的索引功能

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

解决方法:

我认为问题不在于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

我很高兴.

标签:htaccess,hmvc,php,codeigniter-2,codeigniter-hmvc
来源: https://codeday.me/bug/20191008/1873165.html