简体   繁体   中英

Can HTTP 301 response contain custom HTTP header or cookie values?

I found that 301 redirect response in my web service written in PHP doesn't carry custom http headers and custom cookie values if the visit is the very first visit. What I am not sure is whether this is how 301 redirect is supposed to work or whether this is just a matter of how to write my PHP code?

If this is unclear, please clarify and I will make the question clearer. My question is on how http protocol is supposed to behave in this case.

It is possible to add custom HTTP headers to a 301 Redirect response (HTTP 301 Moved Permanently).

For an example of this, visit http://www.hotmail.com which is now redirected to http://www.outlook.com and carries some custom HTTP headers on its 301 redirect response.

ANY response can contain cookies and custom headers. There is nothing in the HTTP spec to prevent 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