21,886
社区成员
发帖
与我相关
我的任务
分享
<xmp>
<?php
$url = 'http://www.liuhangpeiyin.com';
print_r(get_headers($url));
/*
Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Pragma: no-cache
[3] => Content-Type: text/html; charset=utf-8
[4] => Expires: Thu, 19 Nov 1981 08:52:00 GMT
[5] => Server: Microsoft-IIS/8.5
[6] => Set-Cookie: PHPSESSID=d864fe70hki04drrjg6qnrrr50; path=/
[7] => X-Powered-By: ThinkPHP <= 既然你使用了 ThinkPHP,那么就一定会做 url重写配置,可能就是问题的原因
[8] => X-Powered-By: ASP.NET
[9] => Date: Fri, 09 Feb 2018 09:39:23 GMT
[10] => Connection: close
[11] => Content-Length: 68114
)
*/
$url = 'http://www.liuhangpeiyin.com/Uploads/Picture/2018-01-02/5a4afd1919a63.png';
print_r(get_headers($url));
/*
Array
(
[0] => HTTP/1.1 500 Internal Server Error <= 500 服务器拒绝响应
[1] => Content-Type: text/html
[2] => Server: Microsoft-IIS/8.5
[3] => Date: Fri, 09 Feb 2018 09:39:23 GMT
[4] => Connection: close
[5] => Content-Length: 57
)
*/
$url = 'http://www.liuhangpeiyin.com/Uploads/Picture';
print_r(get_headers($url));
/*
Array
(
[0] => HTTP/1.1 301 Moved Permanently <= 这是 301 跳转
[1] => Content-Type: text/html; charset=UTF-8
[2] => Location: http://www.liuhangpeiyin.com/Uploads/Picture/ <= 跳转地址就是访问地址。
[3] => Server: Microsoft-IIS/8.5
[4] => X-Powered-By: ASP.NET
[5] => Date: Fri, 09 Feb 2018 09:39:23 GMT
[6] => Connection: close
[7] => Content-Length: 168
[8] => HTTP/1.1 500 Internal Server Error <= 跳转出现死循环,当然就是 500 错
[9] => Content-Type: text/html
[10] => Server: Microsoft-IIS/8.5
[11] => Date: Fri, 09 Feb 2018 09:39:23 GMT
[12] => Connection: close
[13] => Content-Length: 57
)
*/