简体   繁体   English

使用curl使用php动态转发网址

[英]forward a url using php dynamically using curl

im using a url to download a file. 即时通讯使用网址下载文件。
for example 例如
This url is downloading file 这个网址正在下载文件
url:www.abc.com/get.php?file=1 网址:www.abc.com/get.php文件= 1
how to redirect the same url to another side like xyz.com 如何将同一个网址重定向到另一边,如xyz.com
url:www.xyz.com/get.php?file=1 网址:www.xyz.com/get.php文件= 1
im using this way but its not execuiting and downloading the file from new url 即时通讯使用这种方式,但它不是从新网址执行和下载文件

$url="www.abc.com/get.php?file=1";

$url=str_replace("abc","xyz",$url);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);    
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);

Assuming the PHP on xyz handles the downloading of the file then you shouldn't need curl. 假设PHP on xyz处理文件的下载,那么你不应该需要curl。

$url="www.abc.com/get.php?file=1";

$url=str_replace("abc","xyz",$url);

header("Location: $url");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM