Hi,
I want to configure my home page to redirect clients using WAP or i-mode
browsers. I'm sure this problem must have been tackled by lots of people
already, but I couldn't find any decent material on the subject. This is
what I'm using at the moment:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = =
/* Redirect non-standard user agents */
header("Vary: User-Agent,Accept");
$acc = $_SERVER['HTTP_ACCEPT'];
$accw = strpos($acc, "text/vnd.wap.wml");
$acch = strpos($acc, "text/html");
$accw = ($accw !== false) ? $accw : 9999999;
$acch = ($acch !== false) ? $acch : 9999999;
if ($accw < $acch) {
header("HTTP/1.1 302 Found");
header("Location: http://www.mywebsite.com/wap/");
exit;
}
if (substr($HTTP_USER_AGENT,0,7) == "DoCoMo/") {
header("HTTP/1.1 302 Found");
header("Location: http://www.mywebsite.com/imode/");
exit;
}
= = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Basically this script treats any user agent that identifies itself with a
string starting "DoCoMo/" as an i-mode browser, and redirects to the WML
pages when the string "text/vnd.wap.wml" appears closer to the beginning of
the browser's Accept header than the string "text/html".
This is flawed for (at least) 2 reasons:
1. There are probably other cHTML browsers that would be happier with the
i-mode content, but I don't know how to identify them.
2. The Accept header parsing doesn't recognize the "q=" syntax of Accept
fields.
Before I start re-inventing the wheel, can anyone point me in the direction
of a script that does this sort of thing properly?
Thanks in advance,
Phil
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/