redirect when path_info is not set
This commit is contained in:
parent
8e0575b0a3
commit
be9a2293aa
1 changed files with 12 additions and 2 deletions
14
index.php
14
index.php
|
@ -53,10 +53,20 @@ function getAlbumPreview($dir)
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$shortPath = isset($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : "";
|
|
||||||
if ($shortPath == '/') $shortPath = '';
|
|
||||||
$scriptUrlPath = substr($_SERVER["SCRIPT_NAME"], 0, -4); // trim .php
|
$scriptUrlPath = substr($_SERVER["SCRIPT_NAME"], 0, -4); // trim .php
|
||||||
|
|
||||||
|
// if url == http://localhost/photos/index/toto/titi, path_info == /toto/titi
|
||||||
|
// if url == http://localhost/photos/index, path_info is not set
|
||||||
|
// if url == http://localhost/photos/, path_info is not set
|
||||||
|
// if path_info is not set, we are at top level, so we redirect to /photos/index/
|
||||||
|
if (! isset($_SERVER["PATH_INFO"])) {
|
||||||
|
header("Location: $scriptUrlPath/");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$shortPath = $_SERVER["PATH_INFO"];
|
||||||
|
if ($shortPath == '/') $shortPath = '';
|
||||||
|
|
||||||
$folders = array();
|
$folders = array();
|
||||||
$imageFiles = array();
|
$imageFiles = array();
|
||||||
$otherFiles = array();
|
$otherFiles = array();
|
||||||
|
|
Loading…
Reference in a new issue