1

What is the easiest way to create 1 link that will re-direct to either the App Store, Google Play Store, or a website, depending on the user agent?

  • iOS device should redirect to App Store.
  • Android device should redirect to Google Play.
  • Any other device should redirect to website.
thisiscrazy4
  • 1,767
  • 8
  • 33
  • 55

1 Answers1

2

Use PHP

<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");

if ($iphone || $android || $palmpre || $ipod || $berry == true) 
{ 
header('Location: http://mobile.site.com/');
//OR
echo "<script>window.location='http://mobile.site.com'</script>";
}
?>
Terry
  • 21
  • 1