nginx - 当 php-fpm 和 nginx 为 200 时,php header 位置自动将 http_response_code 设置为 302?

标签 nginx php

代码如下:

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

在apache+php中运行时,http_response_code为200,在nginx + php-fpm中运行时,http_response_code为302。

nginx + php-fpm 会发生什么?

最佳答案

阅读nginx的源代码后,我发现在/src/http/modules/ngx_http_fastcgi_module.c,第1564行,有一些关于将状态码设置为302的代码。

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

响应代码200不会通过fpm传递给nginx,因此响应代码将设置为302

关于nginx - 当 php-fpm 和 nginx 为 200 时,php header 位置自动将 http_response_code 设置为 302?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20121769/

相关文章:

php - 如何从 php 或使用 ejabberd 的直接命令创建 MUC 房间

nginx - GitLab Mattermost 中的 400 Bad Request

redirect - nginx 从客户端浏览器缓存中清除 301 永久

php - 根据输出格式编写查询

PHP 和 MySQL 变量

php - SphinxQL-查询生成器。 PHP 警告 : Packets out of order. 预计收到 0 1。数据包大小=0

php - 使网站登录也适用于 WordPress

nginx - 为什么在 Nginx 中使用 with return 指令时速率限制不起作用?

Kubernetes 上的 PHP-FPM + Nginx

ruby-on-rails - Ubuntu 10.04 中的 "update-rc.d:/etc/init.d/unicorn_app: file does not exist"