When I type in my base url http://localhost/myproject/admin
it keeps on sending me to my permissions page. The http://localhost/myproject/admin
is the base_url().
My core/Controller.php how it works is that it checks if can access the controllers and if is not in the ignore list then gets redirected to permissions else have access to page.
What I would like to know if it is possible to some how to also add my base_url()
so it ignores it and lets me have access to it. I am not sure where would be best to add it in code below.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// I am not using MY_Controller works with Controller fine.
class Controller extends CI_Controller {
public function __construct() {
parent::__construct();
$url = $this->uri->segment(1).'/'.$this->uri->segment(2);
if (isset($url)) {
$route = '';
$segment = explode('/', $url);
if (isset($segment[0])) {
$route .= $segment[0];
}
if (isset($segment[1])) {
$route .= '/' . $segment[1];
}
// $route would equal example: common/dashboard
// $segment[0] folder i.e common
// $segment[1] controller
$ignore = array(
'common/dashboard',
'common/login',
'common/forgotten',
'common/reset',
'error/not_found',
'error/permission'
);
if (!in_array($route, $ignore)) {
redirect('permission');
}
}
}
}