From: Marc MAURICE Date: Thu, 7 Oct 2010 21:13:32 +0000 (+0200) Subject: redirect when path_info is not set X-Git-Tag: v1.0~13 X-Git-Url: http://positon.org/gitweb/?p=bizou.git;a=commitdiff_plain;h=be9a2293aa6122c523518f3991e23ae9f1fdd2a3 redirect when path_info is not set --- diff --git a/index.php b/index.php index b5db265..66f9ff6 100644 --- a/index.php +++ b/index.php @@ -53,10 +53,20 @@ function getAlbumPreview($dir) return ''; } -$shortPath = isset($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : ""; -if ($shortPath == '/') $shortPath = ''; $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(); $imageFiles = array(); $otherFiles = array();