PHP: file_get_contentsfailedtoopenstream: HTTPrequestfailed

Source: Internet
Author: User
Create a test. php {code ...} then access test. php, the error is as follows: Warning: file_get_contents (test1.xiaoci. comcreate. php) [function. file-get-contents]: failedtoopenstream: HTTPrequestfailed! H...

Create a test. php


  

Access test. php and the result is as follows:

Warning: file_get_contents (http://test1.xiaoci.com/create.php) [function. file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in J: \ wamp \ www \ long \ wwwroot \ mytools \ test \ test1.php on line 3

Note:http://test1.xiaoci.comIt is a virtual host I set up locally.
The configuration of a local virtual host is as follows:
Http-vhost.conf


  
       DocumentRoot "d:/wamp/www/"    ServerName test1.xiaoci.com 
  

Hosts

127.0.0.1       test1.com127.0.0.1               test1.xiaoci.com

If 404 is set to return to index. phphttp://test1.xiaoci.com/create.phpBecause create. php does not exist in the URL, it will be forwarded to index. php and processed in index. php.
Manual open ("http://test1.xiaoci.com/create.php") condition: normal access
Usefile_get_contents("http://test1.xiaoci.com/create.php"): Error 404 is reported.

Reply content:

Create a test. php


  

Access test. php and the result is as follows:

Warning: file_get_contents (http://test1.xiaoci.com/create.php) [function. file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in J: \ wamp \ www \ long \ wwwroot \ mytools \ test \ test1.php on line 3

Note:http://test1.xiaoci.comIt is a virtual host I set up locally.
The configuration of a local virtual host is as follows:
Http-vhost.conf


  
       DocumentRoot "d:/wamp/www/"    ServerName test1.xiaoci.com 
  

Hosts

127.0.0.1       test1.com127.0.0.1               test1.xiaoci.com

If 404 is set to return to index. phphttp://test1.xiaoci.com/create.phpBecause create. php does not exist in the URL, it will be forwarded to index. php and processed in index. php.
Manual open ("http://test1.xiaoci.com/create.php") condition: normal access
Usefile_get_contents("http://test1.xiaoci.com/create.php"): Error 404 is reported.

Shouldn't the host be

127.0.0.1 test1.Xiaoci.Com

Why? I saw that the Internet site is indeed 404. In the visual test, you pushed it to the Internet, and the host didn't cover it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.