2013-07-07 66 views
-3

我有一個文件在我的服務器的根目錄:頭重定向到位置不起作用

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

是我的php.ini文件錯誤的地方,或者爲什麼會這樣?

+0

你看到任何錯誤(開機錯誤報告後)?你能否定義「不起作用」 – Lix

+0

@Lix它不重定向到google.com – patriques

+0

沒有即時通訊沒有看到任何錯誤。 – patriques

回答

6

你忘了標題的名字:

header("Location: http://example.com"); 
+0

很抱歉,忘記補充一點。那麼仍然不起作用 – patriques

+0

什麼在錯誤信息?也許標題已經發送?在'header'調用之前添加'ini_set('display_errors',1);''。 –

+0

現在它說:'警告:無法修改頭文件信息 - 已在/Applications/MAMP/htdocs/test/test.php:2中輸出的頭文件(輸出開始於/Applications/MAMP/htdocs/test/test.php) 4號線。你知道爲什麼嗎? – patriques