PDA

View Full Version : iphone Redirect



SmokieMac
03-16-2012, 10:53 AM
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

craigmn3
03-16-2012, 01:11 PM
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>

DaveSawers
03-17-2012, 06:55 AM
The redirect you are seeing must be in the site code somewhere, possibly something like craigmn3's example.

SmokieMac
03-19-2012, 09:16 AM
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.

mathewsimmons
03-30-2012, 02:32 AM
The code redirects to that particular URL . Its redirection for site visit.

SmokieMac
04-05-2012, 11:58 AM
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!

johson
04-08-2012, 07:43 AM
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.

silentg
04-11-2012, 07:55 AM
Have you tried this script detectmobilebrowsers.mobi/? Give it a try if you haven't. Try to implement it into your current site.