I have got my site(mysite.com) to redirect to mysite.com/Mobile for mobile browsers using codeigniters useragent library from my default controller.
When I cache my output from the controller the redirect doesnt work as the browser is served the cached file.
Is there a proper way to go about redirecting from the config/routes.php file? Will this redirect mobile visitors?
My controller
class Child extends Controller {
function child()
{
parent::Controller();
//$this->output->cache(7200);
$agent = $this->agent->browser() . ' ver ' . $this->agent->version();
}
function index()
{
if ($this->agent->is_mobile())
{
header('Location: ' . site_url() . 'Mobile/', TRUE, 301);
exit(0);
}else{
$this->output->cache(7200);
$this->load->view('home',$data);
}
}