In an endpoint of my web service, I am adding some line to http response header and then it is redirected to another url in the service. This is 301 redirection and the header I wrote is removed somehow when this 301 response is sent to the browser.
I am calling header function in PHP to write to header and then calling redirect for 301 redirect. Is there any step I missed? Here is a rough flow:
header("X-my_custom_header:blahblah");
redirect($new_url);
redirect function is calling 3 header functions:
header("HTTP/1.1 301 Moved Permanently");
header( "Cache-Control: no-cache");
header("Location: ".$new_url);
New Finding:
If I move the new header addition line inside redirection function (as 4th line in the function), then I can see the line.
Thanks in advance!