Skip to content

Why codeigniter don't work in linux when I used My_controller?

hengsoheak edited this page Dec 1, 2014 · 1 revision

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

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

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 And I got No URI present. Default controller set.in log file 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

Clone this wiki locally