Forum Moderators: coopster
not sure if that's the right forum, cuz it may have something to do with my apache configuration.
anyways, when I try to check if a given url exists with the file_get_conntents function, it always returns true.
I checked it, and when a page can not be found then it grabs my index page.
it never says:
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in
Can you help?
thanks.
Try using file_exists [php.net] instead. If you are checking a server url on another server, fopen [php.net] will work fine.
dc
thanks for the tip.
Tried that and it turns out these functions behave in the same way.
Looks like all wrapper functions (fopen,fsockopen, file_get_contents etc..) do the same -when they can not reach a given URL, they bounce back to the domain they are called from, for example:
if I call the script from www.mydomain.com/script.php
(where in script.php: fopen ("http://non-existing-url.com", "r");)
and then it grabs content from www.mydomain.com, and thus it always returns true.
I had the same situation on my old box a while ago and my noc fixed it, but since I moved to a self-managed dedicated server I'm not sure what to do.
I think that's apache configuration - but not sure.
DC: if that's not php configuration case (allow_url_open set to ON), would you please move the post to the "apache" group?
thanks.
Warning: file_get_contents(http://www.example.com/somerandomnonsense.txt) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/file-get-contents-error.php on line 5
And the variable will be empty. You've definitely got some server configuration issue.
I wonder if I should just install apache from sources. But I deliberately sticked with those packages, cuz I heard they are really tuned to that distro.
also,
when I ping anything it resolves to that domain:
#root ping ddd
PING ddd.mydomain.com (11.22.33.44) 56(84) bytes of data.
64 bytes from mydomain.com (11.22.33.44): icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from mydomain.com (11.22.33.44): icmp_seq=2 ttl=64 time=0.026 ms