I'm using a simple fopen statement to read a text file, but I get:
fopen(http://www.domain.nl/cees.txt): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
If I call http://www.domain.nl/cees.txt
in my browser, the content displays without any problem, so the file exists (right?)....
I also tried cUrl, but it also returns a 404.
If I try my php-script on another host, it works just fine, so I figured I'd compare the settings for both hosts, but they are identical with allow_url_fopen On in both cases.
There's no htaccess and permissions on rootfolder are 755.
I'm pulling my hair out over this. Anyone has any suggestion?
Here is my try:
The server that can't reach the file is behind a proxy. You may as well be behind the proxy and your browser is configure to go through. But not your php script.
Check your browser's config if it use a proxy. If so, then fopen has to use it too:
$opts= array(
'http' => array(
'proxy' => 'tcp://proxyip:8080',
'header' => array(
"Proxy-Authorization: Basic $auth"
)
)
);
$context = stream_context_create($opts);
$file = fopen($url, 'r', false, $context)
In a moment of clarity I decided to check the httpd.conf and found that the VirtualHost-line for the specified domain contained the IP4-address, but NOT the IP6-address.
I added the IP6-address, restarted Apache and I am happy little bunny!!!
Hope this helps someone else...