-3

I have a file in my server root:

<?php 
  header("Location: http://www.google.com/", true); //this does not work
  //echo "Test"; //this is tested and works.
?>

Is my php.ini file wrong somewhere or why can this be?

patriques
  • 5,057
  • 8
  • 38
  • 48

2 Answers2

6

You forgot name of the header:

header("Location: http://example.com");
OZ_
  • 12,492
  • 7
  • 50
  • 68
  • Sorry forgot to add that. Well still does not work – patriques Jul 07 '13 at 10:01
  • What in error message? Maybe headers are already sent? Add `ini_set('display_errors',1);` before `header` call. – OZ_ Jul 07 '13 at 10:02
  • now it says: `Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/test/test.php:2) in /Applications/MAMP/htdocs/test/test.php on line 4`. Do you know why? – patriques Jul 07 '13 at 10:09
1

remove any and all whitespace before the <?php ... and read How to fix "Headers already sent" error in PHP

Community
  • 1
  • 1
mnagel
  • 6,729
  • 4
  • 31
  • 66