[PHP-users 34902] get_headers() で 存在しないURLを指定しても『HTTP/1.1 200 OK』が返ってくる

竹内宜長 whiskaze @ yahoo.co.jp
2009年 12月 26日 (土) 21:30:23 JST


お世話になります。

---環境-------------
CentOS-5.4
Apache-2.2.14
PHP-5.3.1
--------------------


<?php
$url = 'http://www.hoge.co.jp/';
var_dump(get_headers($url));
?>

$urlに存在しないURLを指定した場合でも200が返ってきます。
array(6) {
  [0]=>
  string(15) "HTTP/1.1 200 OK"
  [1]=>
  string(35) "Date: Sat, 26 Dec 2009 12:04:22 GMT"
  [2]=>
  string(79) "Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14
OpenSSL/0.9.8e-fips-rhel5 PHP/5.3.1"
  [3]=>
  string(19) "Content-Length: 479"
  [4]=>
  string(17) "Connection: close"
  [5]=>
  string(42) "Content-Type: text/html;charset=ISO-8859-1"
}

ただ、URLに『http://www.hoge.co.jp/index.html』とファイル名を指定すれば
404が返ってきます。
array(6) {
  [0]=>
  string(22) "HTTP/1.1 404 Not Found"
  [1]=>
  string(35) "Date: Sat, 26 Dec 2009 12:15:20 GMT"
  [2]=>
  string(79) "Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14
OpenSSL/0.9.8e-fips-rhel5 PHP/5.3.1"
  [3]=>
  string(19) "Content-Length: 327"
  [4]=>
  string(17) "Connection: close"
  [5]=>
  string(43) "Content-Type: text/html; charset=iso-8859-1"
}



ちなみに『http://www.php.net/』を指定すると下記内容が返ってきます。
array(9) {
  [0]=>
  string(15) "HTTP/1.1 200 OK"
  [1]=>
  string(35) "Date: Sat, 26 Dec 2009 12:21:16 GMT"
  [2]=>
  string(46) "Server: Apache/1.3.41 (Unix) PHP/5.2.12RC4-dev"
  [3]=>
  string(31) "X-Powered-By: PHP/5.2.12RC4-dev"
  [4]=>
  string(44) "Last-Modified: Sat, 26 Dec 2009 12:10:22 GMT"
  [5]=>
  string(20) "Content-language: en"
  [6]=>
  string(104) "Set-Cookie: COUNTRY=JPN%2C219.117.254.76; expires=Sat,
02-Jan-2010 12:21:16 GMT; path=/; domain=.php.net"
  [7]=>
  string(17) "Connection: close"
  [8]=>
  string(37) "Content-Type: text/html;charset=utf-8"
}

php.iniやhttpd.comf等の設定ファイルの中身を、
初期状態に戻したりしていろいろ試してみましたが
結果は変わらず、googleで『get_headers 存在しないURL』等で
検索をかけてみましたが、該当する結果に行けず、
ここ3日程度この問題が解決できずにいます。

ご教示を賜りたく、師走のお忙しい時期に
大変恐縮ですが、宜しくお願い致します。



PHP-users メーリングリストの案内