Is it possible to set some http headers while http-redirect(302 or 307)?
Asked Answered
S

2

6

Is it possible to set some http headers while http-redirect(302 or 307)?

<?
 header("some-header: xxx");
 header("Location: http://other.domain.com/foo.php",TRUE,307);

?>
Spiffy answered 4/6, 2011 at 6:23 Comment(0)
R
2

You can basically set whatever http headers you want either as the server or the client.

If you are indicating a redirect you should supply the Location header as your example suggests. You should also ensure that your response headers refer to that response rather than the resource that the client is being redirected to. i.e. your headers here could include Content-Length: 0, omit the Content-Type header and so on.

Not sure if this is what you're after - this question could do with a bit more detail.

Ransack answered 4/6, 2011 at 13:4 Comment(0)
S
-2

You can always do the redirection 301/307. There are ways to do it 1) Do it through java code :

response.setStatus(307);
response.setHeader("Location",url);

2) THe same thing can be done in JSPs.

A tip here is: Always use the setHeader function and not the addHeader function as they behave in different ways.

Stanza answered 25/5, 2012 at 14:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.