Home › Forums › Other › Snippet redirects to iPhone and Android as desired, but how do I go the other way around?!
- This topic is empty.
-
AuthorPosts
-
April 22, 2013 at 4:26 pm #44306EduardoCJMember
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?
Much obliged to those trying to help! :)
Here’s the snippet:
April 22, 2013 at 4:43 pm #132770SenffParticipantOf 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:
if(navigator.userAgent.match(/(iPhone|iPod|Android)/i)) {
window.location.href=”http://www.acueductospr.com/special/redirect.htm”;
} else {
window.location.href=”http://www.acueductospr.com/home.htm”;
}Then the home button on the regular desktop subpages would point to home.html, and not index.html.
Hope that makes sense.
April 22, 2013 at 4:44 pm #132771pixelgridParticipantusing 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
so for
http://www.main-site.com/?from=mobile
if(isset($_GET) && $_GET ===’mobile’) // DONT insert script tagApril 23, 2013 at 1:23 pm #132893EduardoCJMemberThank you both, very much!
April 23, 2013 at 1:25 pm #132894EduardoCJMemberI had a similar problem posted the issue and got to suggested solutions, [https://css-tricks.com/forums/discussion/24363/snippet-redirects-to-iphone-and-android-as-desired-but-how-do-i-go-the-other-way-around#Item_4](https://css-tricks.com/forums/discussion/24363/snippet-redirects-to-iphone-and-android-as-desired-but-how-do-i-go-the-other-way-around#Item_4 “solutions”)
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.