Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 动态前向卷曲请求_Php_.htaccess_Curl - Fatal编程技术网

Php 动态前向卷曲请求

Php 动态前向卷曲请求,php,.htaccess,curl,Php,.htaccess,Curl,我需要动态转发用php编写的CURL请求。 php程序将请求发送到:XYZ.COM 有没有办法将其请求转发到其他位置 我可以使用.htaccess吗 如果有什么解决办法,请告诉我 php脚本是经过编码的&我们无法访问它的源代码。 脚本是基于web的。您试图做的是根据请求转发。由于该头可以自由设置,所以您无法100%地确保收到来自curl客户机的所有请求 想象一下这个cURL命令的执行 curl --user-agent "freetext" http://www.example.com 如果您

我需要动态转发用php编写的CURL请求。 php程序将请求发送到:XYZ.COM

有没有办法将其请求转发到其他位置

我可以使用.htaccess吗

如果有什么解决办法,请告诉我

php脚本是经过编码的&我们无法访问它的源代码。
脚本是基于web的。

您试图做的是根据请求转发。由于该头可以自由设置,所以您无法100%地确保收到来自curl客户机的所有请求

想象一下这个cURL命令的执行

curl --user-agent "freetext" http://www.example.com
如果您自己发送请求,您可以这样做

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://www.example.com");
curl_setopt($ch, CURLOPT_USERAGENT, "myagent");
// ...
// all the other parameters needed 
// taken from http://www.php.net/manual/de/book.curl.php
Apache重写规则如下所示

RewriteCond %{HTTP_USER_AGENT}  ^myagent$
RewriteRule ^(.*)$ https://www.example.com/curl/$1  [L,302]

是否要检测是否有来自CURL的请求?您可以捕获用户代理。如果您发送自己的curl请求,您可以再次使用自己的用户代理并相应地转发这些请求。