<p>When I try to use <code>curl</code> or <code>file_get_contents</code> to read something like <a href="http://example.com/python/json/" rel="nofollow noreferrer">http://example.com/python/json/</a> from <a href="http://example.com/" rel="nofollow noreferrer">http://example.com/</a> I should be getting a JSON response, but instead I get a 404 error. Using curl or any other method outside my own domain works perfectly well.</p>

<pre><code>echo file_get_contents('http://example.com/python/json/'); =&gt; 404
echo file_get_contents('http://google.com'); =&gt; OK
</code></pre>

<p>The same script works on my laptop, but I can't figure out what the difference is.</p>

It looks like example.com is not the default domain for the IP address and that file_get_contents uses HTTP/1.0 instead of HTTP/1.1 and/or does not send a Host: header. Try the curl support in PHP instead:
```
```
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://example.com/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
```
```
Alternatively the /etc/hosts file sets the wrong IP address for example.com.