I have controller welcome
below that redirect to function of another controller in controllers/auth/login.php
function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->library('tank_auth');
}
function index() {
if (!$this->tank_auth->is_logged_in()) {
redirect('/auth/login');
} else {
$data['user_id'] = $this->tank_auth->get_user_id();
$data['username'] = $this->tank_auth->get_username();
$this->load->view('welcome', $data);
}
}
Here, the config.php
:
$config['base_url'] = '';
$config['index_page'] = 'index.php';
it work well. But when i specified the base_url in config file into:
$config['base_url'] = 'http://localhost/cilog/';
$config['index_page'] = '';
Object not found
. why it be? but it work again when i specified index_page
into index.php
.
I believe this is because of the way CodeIgniter handles it's URL's. I'm not actually sure why Codeigniter does this, but they include index.php
in there URL.
So your URL would look something like http://localhost/cilog/index.php/auth/login
You can either rewrite your .htaccess
file to remove the index.php
by putting this in:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
and keep your $config['base_url']
set too "http://localhost/cilog/"
OR
specify both a $config['base_url']
and $config['index_page']
See here for more info: http://ellislab.com/codeigniter/user-guide/general/urls.html (Removing the index.php file)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.