[eluser]Ki[/eluser]
Does anybody have a clue why would header() function work, while CI's redirect() is throwing a blank page. I have observerd it across various controllers. I even tested this right in my main controller, at the very beginning of the code.
Checked logs and error reporting with no result. I am almost 100% sure that nothing is showing up before the headers...
This is my main controller
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
define('HOST1', $_SERVER['HTTP_HOST']);
define('LOGO', 'http://img1.domain.com/logo/logo_v1_bg.gif');
class MY_Controller extends Controller{
function __construct(){
parent::__construct();
$this->setup_assets();
}
function setup_assets(){
//$this->output->enable_profiler(TRUE);
//$this->benchmark->mark('my_controller_start');
if(!isset($this->data['url_array'])) $this->data['url_array'] = $this->uri->uri_to_assoc(2);
//redirect for deleted categories
$this->data['controller'] = $this->uri->segment(1);
$redirect_cat_array=array(
105=>199,
106=>199,
210=>299,
408=>499,
503=>502,
504=>502,
505=>502,
705=>799,
806=>899,
907=>999,
1008=>1099,
1108=>1199,
1209=>1299,
1608=>1699,
1609=>1699,
1305=>1399,
1306=>1399
);
if( isset($this->data['url_array']['catid']) && isset($redirect_cat_array[$this->data['url_array']['catid']]) ){
$redirect_link = str_replace('catid/'.$this->data['url_array']['catid'],'catid/'.$redirect_cat_array[$this->data['url_array']['catid']],$_SERVER['REQUEST_URI']);
//redirect($redirect_link);
header("Location:".$redirect_link,TRUE,301);
}
NOtice above I comented out the redirect() function, because if I enable it and remove header function - I will get a blank page.