Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Snippet redirects to iPhone and Android as desired, but how do I go the other way around?!

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #44306
    EduardoCJ
    Member

    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:


    #132770
    Senff
    Participant

    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:

    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.

    #132771
    pixelgrid
    Participant

    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

    so for

    http://www.main-site.com/?from=mobile
    if(isset($_GET) && $_GET ===’mobile’) // DONT insert script tag

    #132893
    EduardoCJ
    Member

    Thank you both, very much!

    #132894
    EduardoCJ
    Member

    I 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”)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Other’ is closed to new topics and replies.