Edit report at http://bugs.php.net/bug.php?id=53018&edit=1
ID: 53018 Updated by: ahar...@php.net Reported by: techs at remsys dot com Summary: file_get_contents does not follow 301 and 302 redirects -Status: Open +Status: Feedback Type: Bug Package: Apache2 related Operating System: Linux x86_64 CentOS release 5.5 PHP Version: 5.2.14 Block user comment: N New Comment: The redirections are followed for me both in the CLI and Apache SAPIs; I can't see any obvious reason why one would be different to the other. Immediate thoughts: - Does your Apache script set any context options at any point? There is a HTTP context option called "max_redirects" which controls this behaviour -- if it's set to 0, then redirects aren't followed. - Did either (or both) builds have --with-curlwrappers enabled at build time? You can check that in the "Configure Command" line in phpinfo(). Previous Comments: ------------------------------------------------------------------------ [2010-10-07 22:43:32] techs at remsys dot com Description: ------------ Function file_get_contents() does not follow 301 and 302 redirects sub apache module. It returns following: --8< ----------------------- <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> <TITLE>301 Moved</TITLE></HEAD><BODY> <H1>301 Moved</H1> The document has moved <A HREF="http://www.google.com/">here</A>. </BODY></HTML> --8< ----------------------- We got this situation on a 20 servers and even on php-5.2.13, but in the same time it works on others servers with same configuration. Mystery starts when we run this script from command line. It works fine with cli, wich is compiled with same options and use same php.ini. Test script: --------------- <?php echo file_get_contents("http://google.com"); Expected result: ---------------- file_get_contents should follow redirects. Actual result: -------------- Now it doesn't in some cases. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53018&edit=1