Php 将选定的桌面web链接从手机重定向到移动站点
我面临着一个小小的挑战。我有一个网站,也有手机版。当使用手机的用户单击另一个站点(如facebook)的链接时,我希望该用户被重定向到显示所选链接内容的移动站点 成就: 我能够将用户从桌面版本重定向到移动页面 挑战 我无法显示所选链接的内容,例如 它只导航到移动站点,用户必须在那里搜索帖子 我能做什么 这是我的密码Php 将选定的桌面web链接从手机重定向到移动站点,php,redirect,mobile,hyperlink,Php,Redirect,Mobile,Hyperlink,我面临着一个小小的挑战。我有一个网站,也有手机版。当使用手机的用户单击另一个站点(如facebook)的链接时,我希望该用户被重定向到显示所选链接内容的移动站点 成就: 我能够将用户从桌面版本重定向到移动页面 挑战 我无法显示所选链接的内容,例如 它只导航到移动站点,用户必须在那里搜索帖子 我能做什么 这是我的密码 <? include("overall.php");?> <? session_start(); require_once('mobile_device_det
<? include("overall.php");?>
<?
session_start();
require_once('mobile_device_detect.php');
$blackberrystatus = mobile_device_detect(true,true,false,true,true,true,true,false,false);
$androidstatus = mobile_device_detect(true,true,true,true,false,true,true,false,false);
$mobile = mobile_device_detect(true,true,true,true,true,true,true,false,false);
$isMobile = (bool)preg_match('#\b(ip(hone|od)|android\b.+\bmobile|opera m(ob|in)i|windows (phone|ce)|blackberry'.
'|s(ymbian|eries60|amsung)|p(alm|rofile/midp|laystation portable)|nokia|fennec|htc[\-_]'.
'|up\.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\b#i', $_SERVER['HTTP_USER_AGENT'] );
if($_GET["view"]=="full"){
setcookie("passnownow[client]", "pc", $time + 1209600);
$_SESSION["client"] = "pc";
}
if ($_GET["ref"]=="android" or $_GET["ref"]=="blackberry"){
setcookie("passnownow[client]", "app", $time + 1209600);
$_SESSION["client"] = "app";
header('location: mobile/new.php?id=""');
} else if ($_SESSION["client"]=="pc" or $_COOKIE['passnownow']["client"]=="pc"){
}else if ($mobile or $isMobile){
setcookie("passnownow[client]", "mobile", $time + 1209600);
$_SESSION["client"] = "mobile";
**header('location: mobile/new.php?id=""');**
}
include("overall.php");
?>
我的问题是:如何传递标题('location:mobile/new.php?id=“”)
显示所选链接,例如标题('location:mobile/new.php?id=“234”)代码>
我应该添加什么代码来获取所选链接的页面id并将其传递到标题('location:mobile/new.php?id=“”)代码>
我试着使用$\u GET['']
命令,但它不起作用,即头('location:mobile/new.php?id=')代码>您重定向的语法不正确,这可能是您的问题。您将URL变量视为字符串(例如index.php?var=“value”
)。正确的语法应该是
header('Location: mobil/new.php?id=1234');
然后在构建字符串时,您可以执行以下操作
header("Location: mobil/new.php?id={$_GET['id']}");
出于安全原因,您应该始终检查输入
在你上次的陈述中
我尝试使用$\u GET['']命令,但没有成功
标题('location:mobile/new.php?id=
')
您的问题是,当您已经进入PHP时,您正试图进入它。无需使用