简体   繁体   中英

How to redirect/forward request in php?

I use httpful to send http request and get the response to display in request.php

include('httpful.phar');

$response = \Httpful\Request::get('http://domain/response.php')->send();

echo '<textarea rows="20" cols="100">';
echo $response;
echo '</textarea>';

In response.php, I use header to redirect the request to another page, but I cannot get the expected response.

header("HTTP/1.1 301 Moved Permanently");
header("Location:http://otherdomain/other_response.php");

echo 'internal response page'

I have also tried

header("HTTP/1.1 302 Found");

but it still only get the response 'internal response page'

what is the correct way to redirect/forward the request to other_response.php?

From what I know, you may only use header(); once. And it has to output before anything else. From the code that you showed, I don't see any mistakes besides that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM