People who are new to codeigniter often face this issue. Few of the Host Providers have tendency to use the PHP header(); to redirect the Site, So for those kind of specific servers if we are using the PHP header() then it will show us above error. In the Code Igniter the redirect(); function is using the PHP header() to redirect the URL. So this is the reason behind our error.
//Normal Code to redirect
//Alternate Code to fix this issue
$myurl = 'site/function1';
window.location.href = "'.base_url().'index.php?/'.$myurl.'";
Hope this solution helps you too.