简体   繁体   English

php标头位置会自动设置为200,而php-fpm和nginx会将http_response_code设置为302?

[英]php header location auto set http_response_code to 302 when it is 200 with php-fpm and nginx?

code like: 像这样的代码:

<?php
header('Location: http://www.google.com', TRUE, 200);

when run it in apache+php, the http_response_code is 200, but when run it in nginx + php-fpm, the http_response_code is 302. 在apache + php中运行时,http_response_code为200,但在nginx + php-fpm中运行时,http_response_code为302。

what happens in nginx + php-fpm? Nginx + php-fpm中会发生什么?

after read the source code of nginx, i found in /src/http/modules/ngx_http_fastcgi_module.c, line 1564, there are some code about set status code to 302. 读取nginx的源代码后,我在/src/http/modules/ngx_http_fastcgi_module.c的第1564行中找到了一些有关将状态代码设置为302的代码。

header('Location: http://www.google.com', TRUE, 200);

the response code 200 will not pass to nginx by fpm, so the response code will set to 302 响应代码200将不会通过fpm传递给nginx,因此响应代码将设置为302

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM