0

note: There is a similar question but that's about Apache.

The following code

<?php echo '.'; header('Location: http://stackoverflow.com'); 

is fully 'working' under nginx 0.7.67 where 'working' means the php redirect is working fine without errors in the error log or displaying the ..

How can i force nginx or php-fpm to throw the PHP Warning: Cannot modify header information - headers already sent by warning?

2 Answers 2

3

You should check value of output_buffering parameter in your php.ini file.

php.ini #output-buffering

3
  • Thank you, it's totally my fault. There's a framework on two different servers (Apache/nginx) and i thought there's something with nginx so i didn't checked my php.ini :( Thank you, again! Commented Aug 1, 2012 at 12:20
  • What's the "answer" here? In this case, should it be turned off? on? enlarged? Commented Apr 6, 2022 at 4:30
  • 1
    @Ciabaros it should be ON to prevent the error in question. Commented Apr 6, 2022 at 4:37
0

I had the same problem and I found that it was because a header("Status: 200 OK", false, 200); before the header to redirect. So I added a condition not to display the header 200 if I know that I will have to redirect:

if(!isset($_GET['utm_source'])) { //Header will be Redirect 301 from global_cookies.inc.php header("Status: 200 OK", false, 200); } 

Note: With Apache I had not this problem and could redirect even after a header 200.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.