Why My_controller doesn't work in linux hosting?

167 views Asked by At

got empty page when I create MY_controller and Frontend_controller for my website.

Here is Controller

class welcome extends Frontend_controller{
    public function index(){
        $this->load->view('welcome_message');
    }
}

And I also create Frontend_controller in libraries named:Frontend_controller.php

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
 Class Frontend_controller extends MY_controller{ 
     public function __construct(){
         parent::__construct();
          echo'<script>alert()</script>'; 
     }
 }
?>

and I also create MY_controller.php in Core folder

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
Class MY_controller extends CI_controller{
    public $data = array(); 
    public function __construct() { 
        parent::__construct();  
    }
}

?>

for calling all Class name I also copy this function from some tutorial and keep in config.php

function __autoload($classname) {
    if (strpos($classname, 'CI_') !== 0) {
        $file = APPPATH . 'libraries/' . $classname . '.php';
        if (file_exists($file)) {
            @include_once($file);
        }
    }
}

Finaly I create .Htaccess

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteCond %{ENV:REDIRECT_APP_PATH} !^$
RewriteRule ^(.*)$ - [E=APP_PATH:%{ENV:REDIRECT_APP_PATH}]

RewriteCond %{ENV:APP_PATH} ^$
RewriteRule ^(.*)$ - [E=APP_PATH:/$1]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>

I have change and testing this option for URI and $config['base_url'] = ''; too

| 'AUTO'            Default - auto detects
| 'PATH_INFO'       Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'     Uses the REQUEST_URI
| 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'QUERY_STRING';

Here is View welcome_message.php In views fold

Html wrap

But it work in my localhost why it doesn't work on linux hosting ** **Should I change hosting ?

The result I get empty pages when I type welcome or log to my website

I'm really sorry friend I don't know how to do because I spending more time on it. if I can't I will get warning letter from company.

And thank for help

1

There are 1 answers

0
tix3 On

Linux is a case sensitive OS while windows is not. You should change

MY_controller to MY_Controller
CI_controller to CI_Controller

also .Htaccess should be renamed to .htaccess. Empty php pages also known as "white page of death" usually means that you encountered a php fatal error.You should check your logs whenever this happens for a detailed error report (or enable show error if you are NOT in a production server).