Php 这个调试详细信息是什么意思?

Php 这个调试详细信息是什么意思?,php,debugging,curl,Php,Debugging,Curl,我试图通过cURL+PHP获取页面的内容,但它什么也没有给我。当我用google.com替换URL时,它会工作 请求的页面受htaccess保护 这是我的PHP代码 $login = 'admin'; $password = 'xxxxx'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

我试图通过cURL+PHP获取页面的内容,但它什么也没有给我。当我用
google.com
替换URL时,它会工作

请求的页面受htaccess保护

这是我的PHP代码

$login = 'admin';
$password = 'xxxxx';

$ch = curl_init();        
curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']);      
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);    

curl_setopt($ch, CURLOPT_VERBOSE, true);

$verbose = fopen('bla.txt', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");

$output = curl_exec($ch);        
curl_close($ch);  

echo $output;
这是详细信息:

* Hostname was NOT found in DNS cache
*   Trying xxx.xxx.xxx.xxx...
* Connected to xxxxxxxxx (xxx.xxx.xxx.xxx) port 80 (#0)
* Server auth using Basic with user 'admin'
> GET /mypage.php HTTP/1.1

Authorization: Basic YWRtaW46cXdlcnR6dTE=

Host: xxxxxxxxxxxxxx.de

Accept: */*



< HTTP/1.1 301 Moved Permanently

< Date: Fri, 16 Sep 2016 13:44:28 GMT

* Server Apache is not blacklisted
< Server: Apache

< X-Powered-By: PHP/5.4.45

< Expires: Thu, 19 Nov 1981 08:52:00 GMT

< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

< Pragma: no-cache

< Set-Cookie: PHPSESSID=23cd31457358a63a1b32b86992e906bf2; path=/; HttpOnly

< Location: xxxxxxxxxxxxxxxxxxxxxxx

< Content-Length: 0

< Connection: close

< Content-Type: text/html; charset=UTF-8

< 

* Closing connection 0
在DNS缓存中找不到主机名 *正在尝试xxx.xxx.xxx.xxx。。。 *已连接到XXXXXXXX(xxx.xxx.xxx.xxx)端口80(#0) *使用用户“admin”的Basic进行服务器身份验证 >GET/mypage.php HTTP/1.1 授权:基本YWRtaW46cXdlcnR6dTE= 主持人:XXXXXXXXXXXXX.de 接受:*/*
有人能告诉我怎么了吗

HTTP状态代码301表示您试图获取内容的页面的URL已移动到新的URL。您无法使用旧URL检索此网站的内容,但您已收到通知,该网站现在可以通过重定向URL访问

如果可能,通过导航(通过浏览器)到旧URL获取重定向URL,并查看重定向到的位置。然后在卷曲中的这一行使用这个新的重定向URL:

curl_setopt($ch, CURLOPT_URL, $newURL);  

尝试添加
CURLOPT\u FOLLOWLOCATION
并阅读有关
CURLOPT\u FOLLOWLOCATION
和安全模式的更多信息:

cURL正在停止,因为就其而言,工作已经完成。它已获取请求的页面。您看到的响应是301永久重定向头。如果您在浏览器中访问了最初为cURL请求指定的URL,它将自动跟随URL到达指定的目标。cURL不会自动跟随重定向

您可能需要使用
CURLOPT\u FOLLOWLOCATION
选项。将其描述为:

设置为1的长参数告诉库遵循服务器在3xx响应中作为HTTP头的一部分发送的任意位置:头。Location:header可以指定要遵循的相对或绝对URL

您可以在PHP中实现它,如下所示:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
下面是此卷曲选项的示例


如果您不想使用此选项,还可以手动重定向页面,方法是将301 HTTP状态码响应中指定的位置作为URL