I'm new with Codeigniter and this is the first time I encounter this issue. I have a project that has many models, controllers, and multilevel views. All, but one of my controller is not working. I'll try my best to explain my issue.
Let's say I have controller A and Controller B.
Link from view to access each controller:
//This link go to Con A
<a href="<?php print base_url(); ?>ConA/user">TEST1</a>
//This link go to Con B
<a href="<?php print base_url(); ?>ConB/user2">TEST2</a>
Con A
defined('BASEPATH') OR exit('No direct script access allowed');
class ConA extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('MAdmin');
}
public function user()
{
$data = array (
'titlepage' => APP_TITLEPAGE,
'titleapp' => 'User Management',
'listdept' => $this->MAdmin->get_dept(),
'complete' => 'false',
'contentpage' => 'admin/user');//This is the view directory. Will open user.php in myproject/application/views/admin
$this->load->view('shared/master_app', $data);
}
Con B
defined('BASEPATH') OR exit('No direct script access allowed');
class ConB extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('MAdmin');
}
public function user2()
{
$data = array (
'titlepage' => APP_TITLEPAGE,
'titleapp' => 'User Management',
'listdept' => $this->MAdmin->get_dept(),
'complete' => 'false',
'contentpage' => 'admin/user');//This is the view directory. Will open user.php in myproject/application/views/admin
$this->load->view('shared/master_app', $data);
}
shared/master_app in Views
<div class="wrapper wrapper-content"><?php $this->load->view($contentpage); ?></div>
$config
$config['base_url']= "http://".$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
.htaccess in myproject/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myproject
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /myproject/index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
.htaccess in myproject/application
<IfModule authz_core_module>Require all denied</IfModule>
<IfModule !authz_core_module>Deny from all</IfModule>
Note:
- In offline mode (Localhost) everything is run well
- the URL in the address bar after a redirect from the link is the same (except the naming).