Cell phone redirect script

I’ve seen it somewhere, but cant find it. Im looking for a script that would redirect a cell phone to my cell page, rather than to my main page. Thanks

I don’t think it had it’s own thread but was in the WDL for iphone thread. Here is the link:
http://detectmobilebrowsers.mobi/

Thanks for the link. I got the code here…



once('mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'http://www.snoqualmieweather.com/iphone.php',false);


Do you know where I’d place it for it to work?

It is placed on the index page:

require_once("Settings.php");
require_once("common.php");
require_once('mobile_device_detect.php');
mobile_device_detect('http://www.cavecountryweather.com/smartphone/',false,'http://www.cavecountryweather.com/smartphone/','http://www.cavecountryweather.com/cell.php','http://www.cavecountryweather.com/cell.php','http://www.cavecountryweather.com/cell.php','http://www.cavecountryweather.com/cell.php',false,false);;

I just tried placing it where you have it, and it kills my page.

This is what i tried…



require_once("Settings.php");
require_once("common.php");
once('mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'http://www.snoqualmieweather.com/iphone.php',false);


Hi Mark, Looking at drobbins’ code it looks like you’re missing the word ‘require’ for the require_once(‘mobile_device_detect.php’); maybe that is causing the problem.

I was missing the mobile_device_detect.php file

The redirect works on my Android phone now, hopefully it works for every other phone.

Why not include it in some common (header?) file so that it will redirect from any page. Then it would help if someone followed a link to a page other than the index.

hmmmmm :-k not a bad idea… I’ll try messing with that.

I get an error on my phone when i put it in the header

Sorry to abandon you - got side tracked. I checked it out on my HTC Tilt and I see that you got it working. :thumbleft:

Redirection sounds cool, but I am not sure this is such a great idea. I frequently view the full sized version of the website with my Droid on purpose, because the mobile version lacks the full sites info as most mobile sites are just a sub-set of the full sites available info.

By forcing the user to the mobile version, they would get trapped into not being able to access the full site if they want to. The mobile browser my Droid has is quite capable of viewing many full sites, not necessarily as easy (need to zoom in etc), but still able to view it. Even Flash and JavaScripted parts.

Instead, I would use the detection to provide a link that stands out that informs the user of the mobile sites availability and an easy way to get to it.

Its kind of the same thing you can do to notify a user that they have JavaScript turned off. They can use the site, but at least they know why some parts of it might not be working properly.

I did have one ipad user that emailed complaining about the redirect, so the ipad was taken off the redirect list. I still like the redirect because I found that many people have troubles when they are instructed to add a “forward slash smartphone” after cavecountryweather.com. The “forward slash” gets them. :wink: As for those who might want access to the full content sometimes, there is a link on the bottom of the cell pages that goes to index2.php which is exactly the same as the index.php except it does not have the redirect script.

Looking at the page loads, a few people do use the cell page regularly. Rarely is the smartphone page viewed - like only 5 times that I can remember.

Here is how I handle mobile devices. http://discourse.weather-watch.com/p/355978

I think it’s important to let the visitor dtermine ultimately if he wants the mobile or full pages. The link above sets a cookie and allows visitors to switch; the cookie keeps the redirection from happening any more for that session.