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.

Edited by pfpfpf
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.