Ok, so I'm using Jquery's AJAX 开发者_开发问答function and it's having trouble passing a URL with a http address. So I'm hoping to "get" the GET values and send them to another URL — so: a local php file begin passed GET values, which in turn forwards the GET values to another url.
Maybe curl is the answer? I don't know. It's got to be a very short answer I know.
pseudo code:
//retrieve the GET values
$var retrieve [GET]
//passing it to another url
send get values to url ($var, url_address)
edit: It's a cross scripting solution for JavaScript.
If you want to redirect the user:
header('Location: http://example.com/page.php?' . http_build_query($_GET, '', '&')); die();
If however you just want to fetch the page, use this:
file_get_contents('http://example.com/page.php?' . http_build_query($_GET, '', '&'));
If you want to exclude a GET param, just unset()
before using http_build_query()
. It might also be a good idea to include a whitelist of $_GET
params that you'd like to pass around.
header('Location: http://example.com/new?' . http_build_query($_GET));
exit;
Docs. Don't forget to exit()
.
Got it! Thanks Alix Axel!
echo file_get_contents('http://example.com/page.php?'. http_build_query($_GET, '', '&'));
header("Location: http://otherurl.com/page?var=" . $var);
精彩评论