2011-07-28 127 views
0

任何人都知道爲什麼會發生這種情況?php標題位置問題

在我的代碼,我有以下行這個我認爲是造成問題:

header('Location: /var/www/index.php'); 

,但它不斷給我下面的錯誤:

[Thu Jul 28 22:15:18 2011] [error] [client 127.0.0.1] script '/var/www/account/index.php' not found or unable to stat, referer: http://localhost 

可能出現的問題行:

header('Location: /var/www/index.php'); 

文件位於:

/var/www/account/oauth/openid/check.php 

回答

5

您將瀏覽器定向到一個絕對路徑。這是錯誤的,您需要使用相對於文檔根目錄的路徑。瀏覽器無法看到文檔根目錄以外的任何內容。

在你的情況

header('Location: /var/www/index.php'); 

也許應該是:

header('Location: /index.php'); 

由於/var/www/是你的文檔根目錄。

+0

謝謝修復Lekensteyn。一個thinko的位! – Carpetsmoker

3

這會將瀏覽器發送到:/var/www/index.php當您可能只是想將它們發送到index.php

您應該使用與位置頭絕對URL反正所以像:

header('Location: http://mydomain.com/index.php'); 
1

的URL必須在頭()調用來指定,您使用的路徑。嘗試使用index.php的相對位置。

PHP documenation

HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs.