【发布时间】:2014-08-19 15:55:59
【问题描述】:
尝试使用浏览器访问a simple PHP script 我可以找到它。但是,尝试通过curl 或get_headers 访问它会得到 404 结果。比如
$url = 'http://dardesarchat.ir/findme.php';
print_r(get_headers($url, 1));
给予
Array
(
[0] => HTTP/1.1 404 Not Found
[Date] => Sat, 28 Jun 2014 19:38:34 GMT
[Server] => Apache/2
[Accept-Ranges] => bytes
[Vary] => Accept-Encoding,User-Agent
[Connection] => close
[Content-Type] => text/html
)
这与 dns 无关,因为尝试 get_headers 和 http://dardesarchat.ir/index.html 会返回 [0] => HTTP/1.1 200 OK,只有 PHP 文件找不到!
这也与 PHP 无关(如果某些 cookie 丢失,则故意返回 404 等)。 findme.php 中的代码是这样的:
<?php
die('I sure am here :P');
?>
最后,主机上没有htaccess文件。这怎么可能?
【问题讨论】:
-
我尝试从这里卷曲,它可以工作。您是否正在尝试从托管服务器本身
curl/get_headers?有时 Apache 未配置为监听 localhost... -
@Khôi,这发生在远程安装程序上,我在主服务器上有主脚本,在这个服务器上有从属脚本。远程安装程序已经成功安装了 30 多个具有这种精确排列的应用程序实例,尽管它突然为这个特定域给出了这个奇怪的结果。
-
很难说,
index.html真的是您所期待的吗?dardesarchat.ir是否解析到从机上的正确服务器/IP?我想它可能是你到达那里的任何 index.html。 -
@Khôi,好点子!我将添加一个
findme.html来检查是否是这种情况,或者它是否与文件类型有关。 -
@Khôi,你是对的!
http://dardesarchat.ir/findme.html也返回 404!那么,应该是 DNS 相关的,我们可以说 DNS 记录在某些子网中已经更新,而在其他子网中没有?
标签: php curl http-status-code-404