2016-05-16 52 views
-2

我試圖在XAMPP使用頭位置重定向頁面,但它不工作,並重定向到localhost /儀表板PHP標題位置在localhost xampp中不起作用?

我用於本地主機簡單的變向下面的代碼,我把我的網站的htdocs /測試/和該文件是index.html和index.php文件,在index.php代碼如下

<?php 
     header("Location:/index.html"); 
?> 

,當我試圖訪問http://localhost/test/index.php它是不會到localhost /測試/ index.html的 但重定向到http://localhost/dashboard/

+0

你有

+0

不,我沒有任何空間 –

+0

檢查此鏈接它我的幫助http://stackoverflow.com/questions/11072042/headerlocation-redirect-works-on-localhost-but-not-on-remote-server –

回答

0

檢查你的php.ini文件output_buffering = On;然後使用此代碼來重定向到index.html的

<?php 
 
ob_start(); 
 
    if (headers_sent()) { 
 
\t \t 
 
    die("Redirect failed."); 
 
} 
 
else{ 
 
    exit(header("Location: index.html")); 
 
} 
 
?>

你可以從這裏http://php.net/manual/en/function.ob-start.php

+0

甚至使用它的相同問題是否有任何問題與htaccess文件 –

+0

滴滴你檢查你的php.ini文件的output_buffering。無論是打開還是關閉?如果它關閉,那麼ob_start()將無法工作。您是否也將/index.html替換爲index.html? –

+0

是的,我檢查php.ini文件輸出緩衝是打開,我只是複製你的代碼,並放置和檢查沒有工作相同的問題 –

0

得到ob_start的細節我知道你的問題,這應該修復它。

在你的index.php

<?php 
header('Location: ./index.html'); 


?> 

其中./代表當前目錄

+0

不,它不工作我得到同樣的問題 –

+0

沒有工作..... – xamDev

-1

嘗試:

<?php 
echo "<script type=\"text/javascript\" language=\"javascript\"> 
     window.location.replace(\"index.html\"); 
     </script>"; 

?> 
+3

當回答一個問題時,請提供一些背景。 _why_這是答案嗎? _Why_這是否工作? – GrumpyCrouton