redirect() is giving header() error even though nothing is being output to the browser <p>So basically, I'm getting an error message which reads:</p> <blockquote> <p>Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\star\application\controllers\process_login.php:1)</p> </blockquote> <p>I know what is the meaning of that error but I can't figure out where the output was started. I've no whitespaces in the <code>process_login.php</code> file nor anything <code>echo</code>-ed out as well.</p> <p>I access the login form via the <code>http://localhost/star/index.php/star</code> URL</p> <p><strong>star Controller</strong></p> <pre><code>class Star extends CI_Controller { public function index() { $this-&gt;load-&gt;view('login'); } } </code></pre> <p>On form submit, I'm posting to the process_login Controller.</p> <p><strong>process_login Controller (it doesn't even have a closing tag to avoid whitespace)</strong></p> <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Process_login extends CI_Controller { public function index() { $this-&gt;load-&gt;library('form_validation'); $this-&gt;form_validation-&gt;set_rules('userid', 'Username', 'required'); $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'required|callback_check_valid['.trim($this-&gt;input-&gt;post('userid')).']'); if ($this-&gt;form_validation-&gt;run() == FALSE) { $this-&gt;load-&gt;view('login'); } else { redirect('dashboard'); // this is the problem area } } public function check_valid($pw, $un) { if($un) { $this-&gt;load-&gt;model('user'); if($this-&gt;user-&gt;is_authenticated($un, $pw)) { return true; } else { $this-&gt;form_validation-&gt;set_message('check_valid', 'Invalid login. Please try again!'); return false; } } } } /* End of file process_login.php */ </code></pre> <p><strong>dashboard Controller</strong></p> <pre><code>class Dashboard extends CI_Controller { public function index() { $this-&gt;load-&gt;view('admin_area', array('page_title'=&gt;'Dashboard'); } } </code></pre> <p>I'm assuming the <code>process_login.php:1</code> means the output started from Line 1 of that file? If so, I don't have any output or whitespace in that file. Then why is it that I'm getting the error?</p> <h2>Debugging</h2> <p>After removing everything from the <code>process_login.php</code> file, I'm still getting the same error. This is what the stripped down version of the file looks like:</p> <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Process_login extends CI_Controller { public function index() { redirect('dashboard'); } } </code></pre> <p>I'm starting to think the problem might be in some other file which are being loaded before this controller file. Hence, it's saying that the output started from <strong>Line 1</strong>.</p>