-$Args = '';
-$Page = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
-$Page = urldecode(trim($Page, '/')) ?: 'index';
-while (TRUE) {
- if (file_exists("$Page/index.html")) {
- $Page .= '/index';
- break;
- }
- if (file_exists("$Page.html")) {
- break;
+define('DOCROOT', getcwd());
+set_include_path(implode(PATH_SEPARATOR, [ DOCROOT, __DIR__ ]));
+
+include_once 'error.inc.php';
+
+# setup requested page
+
+$request = preg_replace('/\?.*/', '', @$_SERVER['PATH_INFO'] ?: $_SERVER['REQUEST_URI']);
+$request = urldecode(trim($request, '/')) ?: 'index';
+
+$staticpage = "$request.html";
+if (file_exists($staticpage)) {
+ if (is_link($staticpage)) {
+ $target = preg_replace('/\.html$/', '', readlink($staticpage));
+ header("HTTP/1.1 302 Shorthand");
+ header("Location: $target");
+ exit;