我有這樣的基本控制器單一的重定向:重定向循環的笨從基本控制器
class TCMS_Controller extends CI_Controller{
public function __construct(){
parent::__construct();
if(! $this->session->userdata('logged_in')){
redirect('admin/authenticate/login');
}
//Loop to get all settings in the "globals" table
foreach($this->Settings_model->get_global_settings() as $result){
$this->global_data[$result->key] = $result->value;
}
}
}
所以現在我有這個基本的重定向:如果用戶沒有登錄
redirect('admin/authenticate/login');
我也有這個設置可以從網址中刪除index.php
:
.htaccess:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
而旁邊的配置設置:
$config['base_url'] = 'http://something.herokuapp.com/';
$config['index_page'] = '';
,當我試圖訪問管理部分有一個地址:
http://something.herokuapp.com/admin/controller/method
如果我沒有登錄,我應該被重定向到login
頁面:
http://something.herokuapp.com/admin/authenticate/login
但是相反,我得到一個重定向循環
ERR_TOO_MANY_REDIRECTS
如何解決呢?
管理部分:http://tcms.herokuapp.com/admin/authenticate/login http://tcms.herokuapp.com/admin/dashobard
請檢查您的瀏覽器控制檯,看看頁面實際上是否嘗試重定向到。 –
你能否顯示你的刷新url鏈接? –
添加鏈接到網站 – Tachi