我需要能够将第一个uri段“admin”添加到我的列表忽略列表中,但它无法正常工作。它适用于uri segment 2& 3但不是'admin'是uri段1。
如何让它忽略uri segment 1'admin'以及
我使用codeigniter 3和HMVC
$route['admin'] = "admin/common/login/index";
核心/ Controller.php这样
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Controller extends MX_Controller {
public function __construct() {
parent::__construct();
$url = $this->uri->segment(2).'/'.$this->uri->segment(3);
if (isset($url)) {
$route = '';
$part = explode('/', $url);
if (isset($part[0])) {
$route .= $part[0];
}
if (isset($part[1])) {
$route .= '/' . $part[1];
}
$ignore = array(
'common/dashboard',
'common/login', // renamed admin in routes.php
'common/logout',
'common/forgotten',
'common/reset',
'error/not_found',
'error/permission'
);
if (!in_array($route, $ignore, $this->uri->segment(1)) && !$this->permission()) {
redirect('admin/permission');
}
}
}
public function permission() {
$path = $this->uri->segment(2).'/'.$this->uri->segment(3);
return in_array($path, $this->session->userdata('access'));
}
}