Auto redirect to mobile site
I need to redirect mobile devices to the mobile version of my site. How can I do this in Contao? I have a script which detects mobiles then redirects them using:
Code:
header('Location: ../mobile');
I have included this script at the top of my template file but this gives me an error when accessed with an iPhone that says "Too many redirects". If I redirect the script to an external URL it works fine, but this is no use to me as my mobile site is under the same domain as my main site.
Thanks
Re: Auto redirect to mobile site
Did you try using an absolute URL instead?
Also, make sure your redirect code isn't accidentally in the mobile site templates.
Re: Auto redirect to mobile site
Thanks for the reply. Yes you were right, I was using different layouts but both layouts were using the same template. I gave the mobile site a separate template, took out the redirect script and it's all working now.
Re: Auto redirect to mobile site
Hello,
you might also use the redirect extension to do this. It also offers a cookie check so that you can offer your visitors the chance to switch back to the normal version of the web page.
Jan