PHP消息:无法打开流:HTTP请求失败

PHP消息:无法打开流:HTTP请求失败,php,apache,Php,Apache,我使用这个PHP脚本作为代理。 Serer A上的相同脚本可以正常工作,但在服务器B上无法工作,我收到以下错误: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized 及 在服务器B上 允许\u url\u fopen=On 是设置 你知道会出什么问题吗 谢谢 代码似乎没问题。你有没有把你的美元换掉,看看有什么东西进来。在preg_匹配“proxy_url”之前,您没有检查它的健全性。我知道,可能是服务器端的

我使用这个PHP脚本作为代理。 Serer A上的相同脚本可以正常工作,但在服务器B上无法工作,我收到以下错误:

failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized

在服务器B上 允许\u url\u fopen=On

是设置

你知道会出什么问题吗

谢谢
代码似乎没问题。你有没有把你的美元换掉,看看有什么东西进来。在preg_匹配“proxy_url”之前,您没有检查它的健全性。我知道,可能是服务器端的问题,一些配置?假设这是入口点php文件而不是包含,我真的不知道,您尝试过ob_start屏蔽吗?如果文件是在PHP5.4中首先解析的,那么exec'd可能是您应该尝试将?>添加到文件的末尾。空间或cr可能正在溢出。我也会检查浏览器输出。是的,它不是一个包含。谢谢你的建议。
 Cannot modify header information - headers already sent by
<?php
/*
 * in JavaScript call with `encodeURIComponent`
 * $.get('proxy.php?proxy_url='+encodeURIComponent('http://google.com?param=1&param2=2'))
 */
$url = rawurldecode($_GET['proxy_url']);
$cb = ! empty($_GET['callback']) ? $_GET['callback'] : null;

if(preg_match('#ccc\.aaa\.com/bbb/#', $url)){
    $url = preg_replace('#http\://xxx\.xxx\.com/xxx/#', '', $url);
}

if(! preg_match('#^https?:#', $url)){
    $url = preg_replace('#^[\.\/]+#', '', $url);

    if(!file_exists($url)){
        echo 'File not found';
        die(0);
    }
}

if(preg_match('#\.xml$#', $url)){
    header('Content-type: text/xml');
}

$file = file_get_contents($url);

if($cb){
    header('Content-type: application/javascript');
    echo $cb.'('.$file.');';

}else{
    echo $file;
}