xianyu
xianyu

Reputation: 81

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.

what happens in nginx + php-fpm?

Upvotes: 2

Views: 1440

Answers (1)

xianyu
xianyu

Reputation: 81

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.

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

Upvotes: 2

Related Questions