【问题标题】:Redirect Desktop Traffic using html使用 html 重定向桌面流量
【发布时间】:2018-06-30 13:11:39
【问题描述】:

我们正在尝试重定向我们的桌面流量。

例子:

我们有这个子域:

xxxx.domain.com/test

此域用于移动流量,因此,当流量来自桌面时,我们希望重定向到:

domain.com/test

基本上我们有很多移动和桌面登陆页面,但我需要选择桌面登陆需要重定向每个 HTML 页面的流量。

我们如何做到这一点?

【问题讨论】:

标签: html redirect desktop traffic


【解决方案1】:

检查手机(javascript):

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
 window.location.href = 'xxxx.domain.com/test';
}else{
window.location.href = 'domain.com/test';
}

检查移动(PHP):

$android = strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"android");
$ipad = strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"ipad");
$iphone = strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"iphone");
$ipod = strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"ipod");

if (($android === false) && ($ipad === false) && ($iphone === false) && ($ipod === false))
  $mobile = "false";
else 
   $mobile = "true";

【讨论】:

  • 但是要集成到我们的 html 页面中以驱动桌面流量到 domain.com/test 的代码是什么?如果用户使用手机,则保持手机登陆。
  • 谢谢 d.mares。就一个问题。如何将此代码集成到 .html 网站中?那么,我认为这段代码在 .php 中工作对吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-30
  • 1970-01-01
  • 1970-01-01
  • 2011-10-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多