远程服务器不发送响应头,本地服务器

时间:2017-11-13 11:12:13

标签: php http http-headers httpresponse response-headers

我有一个应该发送响应标头的php文件,但它不是。这是本地服务器和远程服务器的网络选项卡。如您所见,本地服务器正在发送许多不同的标头,但远程服务器不发送任何标头。

enter image description here enter image description here

我使用php header()发送了所有响应头,但由于这在本地服务器上完美运行,我猜它是服务器配置问题?如果有人之前有这个问题,请分享一个答案 - 我已经把头发拉了3天了-_-

EDIT认为php代码可能会有所帮助:

<?php 
error_reporting(E_ALL);
//disable browser caching !!IMPORTANT
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: POST, GET"); 
header("Access-Control-Allow-Headers: Random");
header("Access-Control-Expose-Headers: Random");
header("Access-Control-Request-Headers: Random");
在这个php代码之前没有空格。此外,如果此代码出现问题,肯定它无法在我的本地服务器上运行吗?

谢谢, 约什

1 个答案:

答案 0 :(得分:1)

同样的问题是{{3}};

Try to use ob_start(); just after <?php and use ob_end_flush(); at the end of your document.