Php – Using file_get_contents or curl to url on same server

curlfile-get-contentsphprss

I have a PHP script that needs to process the same site's RSS feed. Specifically, I'm displaying the most recent blogs from the WordPress RSS feed on the home page. On our staging server it worked fine but on our live (which is a completely different, but LAMP) hosting environment it's not working.

I can run file_get_contents or curl on a remote url fine, but when I try to retrieve our own RSS feed, I am returned a 404 not found page. One other oddity, if I try file_get_contents(http://domain.com/test.txt) it fails with a 404 but if I do file_get_contents(http://www.domain.com/test.txt) I get the contents of the test text file. This is all assuming I'm running the script from domain.com (not www.domain.com)

I've setup an example here: http://bkwld.com/test.php

Best Solution

Ok, I still don't know why the hell it's doing this, but I'm going to solve it by running my feed through feedburner and then parsing it's RSS feed. Because it's on a remote domain, it works in my tests. Not ideal, but w/e.