Submit Your Article Forum Rules

Results 1 to 8 of 8

Thread: iphone Redirect

  1. #1
    Junior Member SmokieMac's Avatar
    Join Date
    Feb 2009
    Location
    Maine, USA
    Posts
    24

    iphone Redirect

    I searched all over for an answer but couldn't find any clues. Hoping some guru in this group can point me in the right direction.

    Working with a new client, whose most important problem is that their current site uses Flash for the header, including all their navigation, and has no code to offer an alternative. For iphones and ipads, they get blank space, which is what I expect. The mystery comes up when testing a non-flash alternative.

    My own site (which needs an update) is pretty basic html with css, generated by PHP, but nothing fancy. The PHP is only used to include headers, footers, etc. I have a client site that is the same structure, almost identical code other than the content. So two virtually the same coding.

    Note: I'm only interested in the results on iphones where the user has not adjusted the settings; all as it came out of the box. I'm testing on two unmodified iphones, one brand new and one a few years old. Same results as stated below.

    When I go to my site, http://www.bradhadley.com, both iphones redirect to http://m.bradhadley.com. Same result when going to a subfolder, http://www.bradhadley.com/northern/ . Because I don't have a subdomain m.bradhadley.com, it says the site doesn't exist.

    When I go to the virtually identical structured site, http://www.aactowing.ca, it comes up fine. (And because I designed it so the key information is on the left, the key info displays fine on an iphone or any other phone. But the shifting of stuff to the left is just basic use if <div>'s, so there is nothing different from my owns site.

    1) Why are iphones with default settings redirecting my site and not the other?
    2) Why would an iphone, by default, go to m.xxx.com, vs , say, www.xxx.mobi ? Has Apple decided that all mobile sites should be m.xxx.com?
    3) What can I do to my site to ensure it isn't redirected? It appears that the iphones redirect before even looking at the page?

    Thanks for the help!
    Smokie
    Smokie
    Hidden Content (old age satire) - Hidden Content (rant, or good advice)

  2. #2
    Senior Member craigmn3's Avatar
    Join Date
    Jan 2004
    Posts
    487
    Here is a pretty basic script for forwarding all mobile devices. It doesn't preformat to the device, but it gets you there:


    <script type="text/javascript">// <![CDATA[
    var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\s ce|palm/i.test(navigator.userAgent.toLowerCase()));
    if (mobile) {
    document.location = "http://www.mymobliesite.tld";
    }
    // ]]></script>

  3. #3
    WebProWorld MVP DaveSawers's Avatar
    Join Date
    Dec 2006
    Location
    Lunenburg, Nova Scotia, Canada
    Posts
    704
    The redirect you are seeing must be in the site code somewhere, possibly something like craigmn3's example.
    Dynamic Software Development
    Hidden Content

  4. #4
    Junior Member SmokieMac's Avatar
    Join Date
    Feb 2009
    Location
    Maine, USA
    Posts
    24
    Thanks to DaveSawers and Craigmn3 for the responses. I still haven't figured out why this was happening and it wasn't the iphone code that was the problem. I had an index.php file that I had loaded into the root directory by mistake. On all other browsers, the correct file, index.html, came up. On an iphone, it was opening the index.php file. I still can't find anything in the php file that relates to the m.domain.tld that it was looking for. There is no javascript and the only php is an include statement, which failed because the target file top.inc didn't exist. In any case, once I removed the .php file, the iphone displayed the intended site fine, and trying Craigmn3's code worked great too. Will save that for later. Thanks for the help.
    Smokie
    Hidden Content (old age satire) - Hidden Content (rant, or good advice)

  5. #5
    The code redirects to that particular URL . Its redirection for site visit.

  6. #6
    Junior Member SmokieMac's Avatar
    Join Date
    Feb 2009
    Location
    Maine, USA
    Posts
    24
    After my earlier post (that I found an extraneous index file that was confusing iphones), the problem came up on several of my other sites. I noticed that all involved used the same hosting company.

    The hosting company had a free trial of their mobile website service a few months ago and turned it on without asking or notifying clients. This put an entry in the htaccess file that confused iphones, ipads, and some other mobile devices, but not all. I cancelled the free trial, but had to have them change the htaccess file. (They stopped giving clients direct access to htaccess too!).

    Now I have to fix things for about 20 other clients who use this hosting company!
    Smokie
    Hidden Content (old age satire) - Hidden Content (rant, or good advice)

  7. #7
    Banned
    Join Date
    Mar 2012
    Posts
    0
    I believe the above mentioned discussion is valuable for those concerned people. For me personally the info is actually useful. I'm hoping more updates of your*stuff. thanks for sharing good posts.

  8. #8
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Have you tried this script detectmobilebrowsers.mobi/? Give it a try if you haven't. Try to implement it into your current site.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •