-4

我需要编写一个 php 页面,该页面使用自定义查询字符串(本质上是重定向)打开现有 url。

"http://existingurl?test=pass&newparam=".$_REQUEST['u'];

怎么做?

4

3 回答 3

1

像这样:

<?php

header('Location: http://existingurl?test=pass&newparam='.urlencode($_REQUEST['u']));
exit();

?>
于 2012-12-19T20:20:36.273 回答
0

您只需要使用标头功能。不要忘记使用 urlencode 来保护来自 $_REQUEST['u'] 的用户输入。

<?php
    header('Location: http://existingurl?test=pass&newparam='.urlencode($_REQUEST['u']));
    exit();
?>

更多信息,下次可以查看官方文档。 http://php.net/manual/fr/function.header.php

于 2012-12-19T20:21:22.790 回答
0
header('Location: http://existingurl?test=pass&newparam='.urlencode($_REQUEST['u']));
die();

如果您可能的意思是您需要从您的 POST/GET 请求中构建一个具有多个参数的查询字符串,您可能需要查看http_build_query并将其附加到 url

于 2012-12-19T20:27:22.467 回答