Jump to content

http 200 response redirect


pfpfpf

Recommended Posts

I am using PHP fsockopen to get data from a website and this has been working well until today. I am now getting a 200 response  but it indicates "Redirecting..."

Response follows:

 

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 331
Expires: Fri, 03 Aug 2018 00:49:45 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Fri, 03 Aug 2018 00:49:45 GMT
Connection: close

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Redirecting</title>
</head>
<body>
<h3>
    Redirecting...
</h3>
<p>
    If you are not redirected from this page. Please press the 'back' button on your browser.
</p>
<script>
    (function(){
        history.go(-1);
    })();
</script>
</body>
</html>

 

When I manually enter the URL  in a browser then I get the correct information. When PHP accesses the page it gets the above. It there a way for PHP to follow such a redirect? Thanks.

Link to comment
Share on other sites

No, PHP cannot execute Javascript like that.

The page is clearly trying to "redirect" you to the previous page you were visiting. That doesn't make sense with what you're saying. The URL you're fetching is wrong.

But that aside, why are you using fsockopen and not file_get_contents?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.