【问题标题】:Create a URL that redirects to either App Store, Play Store or Website depending on user agent根据用户代理创建一个重定向到 App Store、Play Store 或网站的 URL
【发布时间】:2014-09-05 07:00:54
【问题描述】:

根据用户代理,创建 1 个将重定向到 App Store、Google Play 商店或网站的链接的最简单方法是什么?

  • iOS 设备应重定向到 App Store。
  • Android 设备应重定向到 Google Play。
  • 任何其他设备都应重定向到网站。

【问题讨论】:

    标签: url redirect web


    【解决方案1】:

    使用 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>";
    }
    ?>
    

    【讨论】:

      猜你喜欢
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-11
      • 1970-01-01
      相关资源
      最近更新 更多