Is it possible to set some http headers during http redirects (302 or 307)?

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

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

?>
+5
source share
2 answers

Basically, you can configure any HTTP headers you want, either as a server or as a client.

If you specify a redirection, you must specify the Location header, as your example shows. You must also ensure that the response headers refer to this response and not to the resource to which the client is redirected. those. your headers may include Content-Length: 0, omit the Content-Type header, etc.

, , - .

+2

301/307. 1) java-:

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

2) JSP.

: setHeader, addHeader, -.

-2

All Articles