且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

file_get_contents-无法打开流:HTTP请求失败!找不到HTTP/1.1 404

更新时间:2021-11-16 08:02:28

当我在家中使用一台小型测试服务器时,我也遇到了这个问题.域名被解析为您的外部IP地址,并发送了一个请求.但是由于该请求来自您的网络内部,因此路由器无法将其识别为正常请求.它可能具有用于配置它的Web界面,并尝试从其自己的管理系统返回页面,然后在您指定的路径中找不到该页面.

I've had this problem too, when I working on a little test server at home. The domain name is resolved to your external IP address, and a request is sent. But because the request is coming from inside your network, the router doesn't recognise it as a normal request. It probably has a web interface for configuring it, and tries to return a page from its own management system, which is then not found at the path you specified.

在那种情况下,我在Windows PC上工作,可以通过将要测试的域添加到我的hosts文件中,并指定127.0.0.1作为IP地址(或IP地址的IP地址)来解决该问题.服务器(如果它是同一网络中的另一台计算机).我认为在Linux中应该有一个类似的解决方案.

In that case, I was working on a Windows PC, and I could solve it by adding the domain I was testing to my hosts file, specifying 127.0.0.1 as the IP-address (or the IP-address of the server, if it is another machine within the same network). In Linux there should be a similar solution, I think.

问题不是PHP或服务器,而是路由器.

The problem isn't PHP or your server, but your router.