[英]Forward CURL request on the Fly
I need to forward CURL
requests on the fly that is written in php. 我需要即时转发用PHP编写的CURL
请求。 a php
program send request to: XYZ.COM 一个php
程序将请求发送到:XYZ.COM
is there any way to forward
its request
to another location ? 有什么办法可以forward
其request
forward
到另一个位置?
can i use .htaccess
? 我可以使用.htaccess
吗?
please let me know if there is any solution. 请让我知道是否有解决方案。
php script is encoded & we dont have access to its source code. PHP脚本已编码,我们无权访问其源代码。 script is web based. 脚本是基于Web的。
What you are trying to do is forward request based on User-Agent . 您尝试做的是基于User-Agent的转发请求。 Since that header can be set freely, there is no way you can 100% assure that you are getting all request coming from a curl client. 由于可以自由设置该标头,因此您无法100%确保获得来自curl客户端的所有请求。
Imagine this cURL
command execution 想象一下这个cURL
命令的执行
curl --user-agent "freetext" http://www.example.com
If you are sending the request yourself you could do 如果您自己发送请求,则可以执行
$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
the Apache RewriteRule would look like this Apache RewriteRule看起来像这样
RewriteCond %{HTTP_USER_AGENT} ^myagent$
RewriteRule ^(.*)$ https://www.example.com/curl/$1 [L,302]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.