I use the following code to redirect to a page in PHP. I need to set a custom HTTP headers to pass along with the redirect.
header("Location: http://...");
How can I archive this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This question needs to be answered differently as depending from where you’re looking the answer is different:
Redirect Response (PHP)
As far as you’re concerned about the redirect response (and not the request that may be triggered by a redirect response)
Multiple
headerDocs calls:New Request triggered by a Redirect Response (Browser, HTTP client)
If you’re looking for the new request that has been triggered by a redirect response, please consult your HTTP clients technical documentation for your options.
Commonly, HTTP clients do not offer any such options, that is most HTTP clients do not turn response headers into request headers in case one of the response headers is a
Location:header and a status code in the 3xx range.This would not make any sense anyway as such practice would be unsafe.
Especially on the level of interactive HTTP clients (like a browser) that automatically perform redirects without approval of the user. See HTTP, compare Fetch API.
Further reading: https://ec.haxx.se/http/http-redirects