PHP / HTML查询字符串从URL链接中删除

时间:2018-07-22 18:11:02

标签: php html redirect tracking

我正在尝试传递包含完整网址的链接;

http://xxx.co.uk/trackit.php?page=http://xxx.co.uk/game?p=buildings&menu

正如您在上面的链接中看到的那样,首先进入一个名为trackit的脚本,进行一些跟踪,然后重定向到我想要的实际页面,但是在这种情况下,“&menu”被删除了,我想我理解为什么,但无法修复。

$next_page = mysqli_real_escape_string($con, $_GET['page']);
header("Location: $next_page");

任何建议都会很棒。 谢谢

1 个答案:

答案 0 :(得分:1)

//before display your url
$page = urlencode('http://xxx.co.uk/game?p=buildings&menu');
$url = 'http://xxx.co.uk/trackit.php?page=' . $page;

echo $url;
// displays
// http://xxx.co.uk/trackit.php?page=http%3A%2F%2Fxxx.co.uk%2Fgame%3Fp%3Dbuildings%26menu


//when you receive it on the get
$next_page = urldecode($_GET['page']);
header("Location: $next_page");