Skip to content
Advertisement

How do I ignore a moved-header with file_get_contents in PHP?

I have programmed a simple content-user, that uses file_get_contents, but unfortunately for my IP the site now gives a 302 error that forwards to an image. For all other users the normal site is viewable.

How do I rewrite the get_contents so it will just download the content of the website and not actually follow the redirect?

$html = file_get_contents("http://www.site.net/");

Advertisement

Answer

There is no content there. The redirect happens in the HTTP response before any content would be sent.

The server decides what you get to see (or not).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement