I have a snippet on my homepage (index.htm), and as desired will automatically take my visitors using an iPhone or Android device to a redirection page, where they either choose the mobile version or the full site. When choosing the full site, they were REDIRECTED back to that page. I solved the issue redirecting to a second version of my homepage w/o the snippet.
Of course, anytime they clic on any home button within any of the full site’s sub pages they’ll be taken back to the redirection page!
Is there a way to solve this looping issue, w/o having a second version of my index.htm page with no snippett?
Of course, the cliche solution would be to say “make your site responsive and you won’t have to deal with redirects!” but I guess that’s not what you’re looking for right now and that would take a while to fix. ;)
I would put the redirect script on a main INDEX page, not a HOME page. Then when the user first lands on this main index page, he will be redirected to either the mobile version, OR the (regular) desktop version, something like this:
using php you can check to see if $_SERVER is the same as your mobile version domain and conditionaly insert the script tag.
as quoted on php.net though
> The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
Another solution is when you redirect them back to your home page you can set a variable through the site address and check it with superglobal $_GET