This will help with passing context along to inner pages that need to
route based on their own request path context without needing to
recalculate it in every route.
// May contain query params
$request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);
+$pieces = array_values(array_filter(
+ explode('/', $request_uri[0]),
+ function($exploded) { return $exploded; }
+));
-switch ($request_uri[0]) {
- case '/':
+if (empty($pieces)) {
+ require './app.php';
+ die;
+}
+
+$path = array_shift($pieces);
+
+switch ($path) {
+ case '':
require './app.php';
break;
- case '/upload':
+ case 'upload':
require './upload.php';
break;
- case '/unauthorized':
+ case 'unauthorized':
require './unauthorized.php';
break;
default: