Php 接受远程域get/post请求

Php 接受远程域get/post请求,php,apache,Php,Apache,我在一个不接受请求(get/post)远程域的linux服务器上工作。比如,如果我在另一个域上使用表单并将其发布到该服务器上的脚本中,它就不会处理它。我想知道我必须启用哪些选项才能完成此操作,以便它接受远程请求?它是否在php.ini中 关于如果web服务器通过推荐人阻止帖子,您需要找到从您的网站发送推荐人的方法。首先将帖子发送到脚本,然后从脚本发送到您的站点,这样您就有可能伪造推荐人请求标题 下面是从这里借用的php代理示例代码: 这种行为很可能是通过Web服务器配置的。如果我不得不阻止来自

我在一个不接受请求(get/post)远程域的linux服务器上工作。比如,如果我在另一个域上使用表单并将其发布到该服务器上的脚本中,它就不会处理它。我想知道我必须启用哪些选项才能完成此操作,以便它接受远程请求?它是否在php.ini中


关于

如果web服务器通过推荐人阻止帖子,您需要找到从您的网站发送推荐人的方法。首先将帖子发送到脚本,然后从脚本发送到您的站点,这样您就有可能伪造推荐人请求标题

下面是从这里借用的php代理示例代码:



这种行为很可能是通过Web服务器配置的。如果我不得不阻止来自其他域(而不是php)的帖子,我会在apache中使用mod_rewrite?您在使用ajax吗?是的,我正在请求使用ajax获取/发布。@Spliffster,服务器是专用的,所以如果需要更改任何内容,我都没有问题。只需要找出这种行为的原因。
<?php
// PHP Proxy
// Responds to both HTTP GET and POST requests
//
// Author: Abdul Qabiz
// March 31st, 2006
//

// Get the url of to be proxied
// Is it a POST or a GET?
$url = ($_POST['url']) ? $_POST['url'] : $_GET['url'];
$headers = ($_POST['headers']) ? $_POST['headers'] : $_GET['headers'];
$mimeType =($_POST['mimeType']) ? $_POST['mimeType'] : $_GET['mimeType'];


//Start the Curl session
$session = curl_init($url);

// If it's a POST, put the POST data in the body
if ($_POST['url']) {
$postvars = '';
while ($element = current($_POST)) {
$postvars .= key($_POST).'='.$element.'&';
next($_POST);
}
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
}

// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false);

curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

// Make the call
$response = curl_exec($session);

// NOTE: HERE YOU WILL OVERRIDE THE REFERRER REQUEST HEADER
if ($mimeType != "")
{
// The web service returns XML. Set the Content-Type appropriately
header("Content-Type: ".$mimeType);
}

echo $response;

curl_close($session);

?>