所以我有這三個子文件夾。該文件夾代表三個用戶。我有這個session.php
這將檢查用戶的「ID」,請它將繼續登錄,但如果現在將您重定向到index.php
如何將PHP重定向到根目錄index.php
這裏是我的代碼session.php
<?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if (!isset($_SESSION['username']) || (trim($_SESSION['username']) == '')) {
header("Location: index.php");
exit();
}
$session_id=$_SESSION['username'];
?>
我知道代碼是正確的,我唯一的問題是header(); 例如,當我輸入的位置/ rootFolder /子文件夾/ file.php
它會給我的PHP錯誤未找到對象或文件不存在
你絕對需要證明從'位置/ rootFolder產生錯誤的代碼的一個子集/ SubFolder/file.php',否則你可能會得到比彩票組合更糟糕的答案。 –
[在PHP中獲取webroot]的可能重複(http://stackoverflow.com/questions/2424606/get-webroot-in-php) – fyrye
只需在'index.php'之前添加'/'。 'header(「Location:/index.php」)' – roullie